// public static bool isInCone(OBVector3 x, OBVector3 apex, OBVector3 axis, double aperture ) // { // //got it from here:http://stackoverflow.com/questions/10768142/verify-if-point-is-inside-a-cone-in-3d-space // //test if point x is inside an infinite cone defined by apex point with normal vector axis and aperture angle(in radians) // double halfAperture=aperture/2; // OBVector3 apexToXVect = OBVector3(apex,x); // OBVector3. // bool insideCone = StarMath.dotProduct(apex,axis)/StarMath.norm2(apexToXVect)/StarMath.norm2(axis) > Math.Cos(aperture); // return insideCone; // } public static bool atomsInCarboxylateCone(OBAtom a, OBAtom carba, OBMol mol) { //angle should probably not be hardcoded double aperture = 120 * Math.PI / 180; double[] axis = obvec2dubs(OBVector3.Sub(carba.GetVector(), a.GetVector())); //axis = StarMath.divide (axis, StarMath.norm2 (axis)); double[] apex = obvec2dubs(carba.GetVector()); List <uint> exclude = new List <uint>(); exclude.Add(carba.GetIdx()); foreach (OBBond b in carba.Bonds()) { OBAtom other = b.GetNbrAtom(carba); if (other != a) { exclude.Add(other.GetIdx()); } } foreach (OBAtom n in mol.Atoms()) { if (!exclude.Contains(n.GetIdx())) { double[] x = obvec2dubs(n.GetVector()); //if any point is found to be in the carboxylate's cone, return true if (isInCone(x, apex, axis, aperture)) { return(true); } } } return(false); }
public static double radial_weight(OBMol mol, OBAtom carbon1, OBAtom a1) { OBVector3 compos = mol_com(mol); OBVector3 v2 = carbon1.GetVector(); OBVector3 v3 = a1.GetVector(); return(openbabel_csharp.Point2Line(compos, v2, v3)); }
public static double atomdist(OBAtom a0, OBAtom a1) { OBVector3 disp = OBVector3.Sub(a0.GetVector(), a1.GetVector()); double x = disp.GetX(); double y = disp.GetY(); double z = disp.GetZ(); double dist = Math.Sqrt(x * x + y * y + z * z); return(dist); }
public static double atom2linedistance(OBAtom x0, OBAtom a1, OBAtom a2) { //a1 and a2 are atoms that define the axis in question, x0 is the atom that we want to know the distance from the axis OBVector3 v0 = x0.GetVector(); OBVector3 v1 = a1.GetVector(); OBVector3 v2 = a2.GetVector(); return(openbabel_csharp.Point2Line(v0, v1, v2)); }
public static double pairwiseangle(OBAtom carbon1, OBAtom a1, OBAtom carbon2, OBAtom a2) { //carbon1 and carbon2 are carbon atoms connected to oxygen //a1 and a2 connect to carbon1 and carbon2 respectively OBVector3 vec1 = OBVector3.Sub(carbon1.GetVector(), a1.GetVector()); OBVector3 vec2 = OBVector3.Sub(carbon2.GetVector(), a2.GetVector()); double angle = angle_between_vectors(vec1, vec2); return(angle); }
public static double greatest_axial_distance(OBMol mol, OBAtom carbon1, OBAtom a1) { //finds the distance of the most distant atom along the axis defined by the carboxyl defined by carbon 1 and a1 double[] vec = obvec2dubs(OBVector3.Sub(carbon1.GetVector(), a1.GetVector())); vec = StarMath.normalize(vec); double maxd = 0; foreach (OBAtom a in mol.Atoms()) { if (a == carbon1) { continue; } double d = StarMath.dotProduct(vec, obvec2dubs(OBVector3.Sub(carbon1.GetVector(), a.GetVector()))); // get pairwise axial distance by taking the scalar projection of the carbon's position to atom A if (d > maxd) { maxd = d; } } return(maxd); }
public static double greatest_radial_distance(OBMol mol, OBAtom carbon1, OBAtom a1) { OBVector3 v2 = carbon1.GetVector(); OBVector3 v3 = a1.GetVector(); double maxd = 0; foreach (OBAtom a in mol.Atoms()) { OBVector3 v1 = a.GetVector(); double d = openbabel_csharp.Point2Line(v1, v2, v3); if (d > maxd) { maxd = d; } } return(maxd); }
public static OBMol connect_within_radius(OBMol mol, OBAtom n, double radius) { foreach (OBAtom a in mol.Atoms()) { if (a.GetIdx() == n.GetIdx()) { continue; } else { double len = Math.Round(StarMath.norm2(obvec2dubs(OBVector3.Sub(a.GetVector(), n.GetVector()))), 7); //gets length if (len <= radius) { mol.AddBond((int)a.GetIdx(), (int)n.GetIdx(), 1); } } } return(mol); }