/// <summary> /// Generates a slightly larger transparent sphere to highlight the atom. /// Creates a slightly larger sphere using GenerateSphere out of the backend. /// Applies a transparent solid color brush and an emissive material to the mesh. /// Adds the model to the modelGroup /// </summary> /// <param name="atom">Atom that is being highlighted</param> private void MakeAtomHighlight(Atom atom) { // .8 angstrom is slightly larger than any of the atoms MeshGeometry3D mesh = m_backend.GenerateSphere(new Point3D(atom.X, atom.Y, atom.Z), .8, 9, 9); GeometryModel3D geomod = new GeometryModel3D(); geomod.Geometry = mesh; SolidColorBrush solidBrush = new SolidColorBrush(Colors.Yellow); solidBrush.Opacity = .5; geomod.Material = new EmissiveMaterial(solidBrush); m_myModel3DGroup.Children.Add(geomod); }
/// <summary> /// Creates the 3d atom model. Calls GenerateSphere out of the backend to make the mesh. /// Applies a solid color brush and diffuse material to the mesh to texture the model. /// Adds the model to the modelGroup /// </summary> /// <param name="atom">The atom that is being represented</param> /// <param name="radius">Radius of the sphere to generate</param> /// <param name="color">Color of the sphere to generate</param> private void MakeAtom(Atom atom, double radius, Color color) { MeshGeometry3D mesh = m_backend.GenerateSphere(new Point3D(atom.X, atom.Y, atom.Z), radius, 9, 9); GeometryModel3D geomod = new GeometryModel3D(); geomod.Geometry = mesh; SolidColorBrush solidBrush = new SolidColorBrush(color); geomod.Material = new DiffuseMaterial(solidBrush); m_myModel3DGroup.Children.Add(geomod); }
/// <summary> /// For an alpha carbon on protein 1, it will find the nearest alpha carbon in protein 2. /// It then creates a ResNumPair object to be added to the m_CAPair list for RMSD calculations. /// </summary> /// <param name="a_CAIndex">Index in the list of proteins for the alpha carbon on protein 1</param> /// <returns>Distance between the two alpha carbons</returns> private double Nearest(int a_CAIndex) { double NearDist = double.PositiveInfinity; Atom pairedAtom = new Atom(); if (a_CAIndex < Protein1.Count) { double templateX = Protein1.Atoms[a_CAIndex].X; double templateY = Protein1.Atoms[a_CAIndex].Y; double templateZ = Protein1.Atoms[a_CAIndex].Z; foreach (Atom atom in Protein2.Atoms) { if (atom.CA) { //distance in 3d space double tempDist = Math.Sqrt(Math.Pow(atom.X - templateX, 2) + Math.Pow(atom.Y - templateY, 2) + Math.Pow(atom.Z - templateZ, 2)); if (tempDist < NearDist) { NearDist = tempDist; pairedAtom = atom; } } } } else { throw (new Exception("Distance calculation error: Template CAIndex out of range.")); } m_CAPair.Add(new ResNumPair(Protein1.Atoms[a_CAIndex].Residue_Num, pairedAtom.Residue_Num, Protein1.Atoms[a_CAIndex].Chain, pairedAtom.Chain,NearDist)); return NearDist; }