Example #1
0
		// copied from sheet -- not correct
        public override void calcAxis()
		{
			if (axisA != null)
				return ;
			
			axisA = new Point3f();
			if (lowerNeighborIsHelixOrSheet())
				apolymer.getLeadMidPoint(monomerIndex, axisA);
			else
				apolymer.getLeadMidPoint(monomerIndex + 1, axisA);
			
			axisB = new Point3f();
			if (upperNeighborIsHelixOrSheet())
				apolymer.getLeadMidPoint(monomerIndex + monomerCount, axisB);
			else
				apolymer.getLeadMidPoint(monomerIndex + monomerCount - 1, axisB);
			
			axisUnitVector = new Vector3f();
			axisUnitVector.sub(axisB, axisA);
			axisUnitVector.normalize();
			
			Point3f tempA = new Point3f();
			apolymer.getLeadMidPoint(monomerIndex, tempA);
			projectOntoAxis(tempA);
			Point3f tempB = new Point3f();
			apolymer.getLeadMidPoint(monomerIndex + monomerCount, tempB);
			projectOntoAxis(tempB);
			axisA = tempA;
			axisB = tempB;
		}
        public virtual void calc1Screen(Point3f center, Vector3f vector, short mad, float offsetFraction, Point3i screen)
		{
			pointT.set_Renamed(vector);
			float scale = mad * offsetFraction;
			pointT.scaleAdd(scale, center);
            //viewer.transformPoint(pointT, screen);
		}
 public virtual Point3i[] calcScreens(Point3f[] centers, Vector3f[] vectors, short[] mads, float offsetFraction)
 {
     // this basically does object->screen transformation??
     Point3i[] screens = new Point3i[centers.Length];// viewer.allocTempScreens(centers.Length);
     if (offsetFraction == 0)
     {
         for (int i = centers.Length; --i >= 0; )
             screens[i] = new Point3i((int)centers[i].x, (int)centers[i].y, (int)centers[i].z);
             //viewer.transformPoint(centers[i], screens[i]);
     }
     else
     {
         offsetFraction /= 1000;
         for (int i = centers.Length; --i >= 0; )
         {
             pointT.set_Renamed(vectors[i]);
             float scale = mads[i] * offsetFraction;
             pointT.scaleAdd(scale, centers[i]);
             //if (float.IsNaN(pointT.x))
             //{
             //    System.Console.Out.WriteLine(" vectors[" + i + "]=" + vectors[i] + " centers[" + i + "]=" + centers[i] + " mads[" + i + "]=" + mads[i] + " scale=" + scale + " --> " + pointT);
             //}
             //viewer.transformPoint(pointT, screens[i]);
             screens[i] = new Point3i((int)pointT.x, (int)pointT.y, (int)pointT.z);
         }
     }
     return screens;
 }
Example #4
0
        public override void calcAxis()
		{
			if (axisA != null)
				return ;
			if (monomerCount == 2)
			{
				axisA = aminoPolymer.getLeadPoint(monomerIndex);
				axisB = aminoPolymer.getLeadPoint(monomerIndex + 1);
			}
			else
			{
				axisA = new Point3f();
				aminoPolymer.getLeadMidPoint(monomerIndex + 1, axisA);
				axisB = new Point3f();
				aminoPolymer.getLeadMidPoint(monomerIndex + monomerCount - 1, axisB);
			}
			
			axisUnitVector = new Vector3f();
			axisUnitVector.sub(axisB, axisA);
			axisUnitVector.normalize();
			
			Point3f tempA = new Point3f();
			aminoPolymer.getLeadMidPoint(monomerIndex, tempA);
			if (!lowerNeighborIsHelixOrSheet())
				projectOntoAxis(tempA);
			Point3f tempB = new Point3f();
			aminoPolymer.getLeadMidPoint(monomerIndex + monomerCount, tempB);
			if (!upperNeighborIsHelixOrSheet())
				projectOntoAxis(tempB);
			axisA = tempA;
			axisB = tempB;
		}
        public virtual void render1Chain(int monomerCount, Monomer[] monomers, Point3f[] centers, Vector3f[] vectors, short[] mads, short[] colixes)
		{
			Point3i[] ribbonTopScreens;
			Point3i[] ribbonBottomScreens;
			
			ribbonTopScreens = calcScreens(centers, vectors, mads, isNucleic?1f:0.5f);
			ribbonBottomScreens = calcScreens(centers, vectors, mads, isNucleic?0f:- 0.5f);
			render2Strand(monomerCount, monomers, mads, colixes, ribbonTopScreens, ribbonBottomScreens);
            //viewer.freeTempScreens(ribbonTopScreens);
            //viewer.freeTempScreens(ribbonBottomScreens);
		}
        public virtual Point3i[] calcScreens(Point3f[] centers, Vector3f[] vectors, short[] mads, float offsetFraction)
		{
			int count = centers.Length;
            Point3i[] screens = new Point3i[count];// null;// viewer.allocTempScreens(count);
			if (offsetFraction == 0)
			{
                for (int i = count; --i >= 0; )
                    screens[i] = new Point3i((int)centers[i].x, (int)centers[i].y, (int)centers[i].z);
                //    viewer.transformPoint(centers[i], screens[i]);
			}
			else
			{
				for (int i = count; --i >= 0; )
				{
					pointT.set_Renamed(vectors[i]);
					//boolean isSpecial = isSpecials[i];
					short mad = mads[i];
					/*
					if (isSpecial && !lastWasSpecial)
					mad *= 2;
					*/
					/*
					short mad = isSpecial || i == 0 ? mads[i] : mads[i - 1];
					if (i + 1 < count && isSpecial) {
					if (isSpecial && ! isSpecials[i + 1])
					mad = mads[i];
					}
					*/
					float scale = mad * offsetFraction;
					pointT.scaleAdd(scale, centers[i]);
                    screens[i] = new Point3i((int)pointT.x, (int)pointT.y, (int)pointT.z);
                    //viewer.transformPoint(pointT, screens[i]);
				}
			}
			return screens;
		}
Example #7
0
 public float getAngle(int atomIndexA, int atomIndexB, int atomIndexC)
 {
     if (vectorBA == null)
     {
         vectorBA = new Vector3f();
         vectorBC = new Vector3f();
     }
     Point3f pointA = atoms[atomIndexA].point3f;
     Point3f pointB = atoms[atomIndexB].point3f;
     Point3f pointC = atoms[atomIndexC].point3f;
     vectorBA.sub(pointA, pointB);
     vectorBC.sub(pointC, pointB);
     float angle = vectorBA.angle(vectorBC);
     float degrees = toDegrees(angle);
     return degrees;
 }
Example #8
0
		/// <summary> Constructs and initializes an AxisAngle4f from the specified 
		/// axis and angle.
		/// </summary>
		/// <param name="axis">the axis
		/// </param>
		/// <param name="angle">the angle of rotation in radians
		/// 
		/// </param>
		/// <since> Java 3D 1.2
		/// </since>
		public AxisAngle4f(Vector3f axis, float angle)
		{
			this.x = axis.x;
			this.y = axis.y;
			this.z = axis.z;
			this.angle = angle;
		}
Example #9
0
		/// <summary> Sets the value of this AxisAngle4f to the specified 
		/// axis and angle.
		/// </summary>
		/// <param name="axis">the axis
		/// </param>
		/// <param name="angle">the angle of rotation in radians
		/// 
		/// </param>
		/// <since> Java 3D 1.2
		/// </since>
		public void  set_Renamed(Vector3f axis, float angle)
		{
			this.x = axis.x;
			this.y = axis.y;
			this.z = axis.z;
			this.angle = angle;
		}
Example #10
0
		/// <summary> Returns the angle in radians between this vector and
		/// the vector parameter; the return value is constrained to the
		/// range [0,PI].
		/// </summary>
		/// <param name="v1"> the other vector
		/// </param>
		/// <returns> the angle in radians in the range [0,PI]
		/// </returns>
		public float angle(Vector3f v1)
		{
			// return (double)Math.acos(dot(v1)/v1.length()/v.length());
			// Numerically, near 0 and PI are very bad condition for acos.
			// In 3-space, |atan2(sin,cos)| is much stable.
			
			double xx = y * v1.z - z * v1.y;
			double yy = z * v1.x - x * v1.z;
			double zz = x * v1.y - y * v1.x;
			double cross = System.Math.Sqrt(xx * xx + yy * yy + zz * zz);
			
			//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
			return (float) System.Math.Abs(System.Math.Atan2(cross, dot(v1)));
		}
Example #11
0
		/// <summary> Constructs and initializes a Vector3f from the specified Vector3f.</summary>
		/// <param name="v1">the Vector3f containing the initialization x y z data
		/// </param>
		public Vector3f(Vector3f v1):base(v1)
		{
		}
Example #12
0
        public Point3i transformPoint(Point3f pointAngstroms, Vector3f vibrationVector)
		{
            return null;// transformManager.transformPoint(pointAngstroms, vibrationVector);
		}
Example #13
0
		/// <summary> Modifies the translational components of this matrix to the values of
		/// the Vector3f argument; the other values of this matrix are not modified.
		/// </summary>
		/// <param name="trans">the translational component
		/// </param>
		public virtual void  setTranslation(Vector3f trans)
		{
			m03 = trans.x;
			m13 = trans.y;
			m23 = trans.z;
		}
Example #14
0
		/// <summary> Retrieves the translational components of this matrix.</summary>
		/// <param name="trans">the vector that will receive the translational component
		/// </param>
		public void  get_Renamed(Vector3f trans)
		{
			trans.x = m03;
			trans.y = m13;
			trans.z = m23;
		}
Example #15
0
        public void transformVector(Vector3f vectorAngstroms, Vector3f vectorTransformed)
		{
            //transformManager.transformVector(vectorAngstroms, vectorTransformed);
		}
Example #16
0
		/// <summary> Constructs and initializes a Matrix4f from the rotation matrix,
		/// translation, and scale values; the scale is applied only to the
		/// rotational components of the matrix (upper 3x3) and not to the
		/// translational components.
		/// </summary>
		/// <param name="m1"> The rotation matrix representing the rotational components
		/// </param>
		/// <param name="t1"> The translational components of the matrix
		/// </param>
		/// <param name="s"> The scale value applied to the rotational components
		/// </param>
		public Matrix4f(Matrix3f m1, Vector3f t1, float s)
		{
			set_Renamed(m1);
			mulRotationScale(s);
			setTranslation(t1);
			m33 = 1.0f;
		}
Example #17
0
		/// <summary> Performs an SVD normalization of this matrix to calculate the rotation
		/// as a 3x3 matrix, the translation, and the scale. None of the matrix values are modified.
		/// </summary>
		/// <param name="m1">The normalized matrix representing the rotation
		/// </param>
		/// <param name="t1">The translation component
		/// </param>
		/// <returns> The scale component of this transform
		/// </returns>
		public float get_Renamed(Matrix3f m1, Vector3f t1)
		{
			get_Renamed(t1);
			return SVD(m1, null);
		}
Example #18
0
		/// <summary> Constructs and initializes a Matrix4f from the quaternion,
		/// translation, and scale values; the scale is applied only to the
		/// rotational components of the matrix (upper 3x3) and not to the
		/// translational components.
		/// </summary>
		/// <param name="q1"> The quaternion value representing the rotational component
		/// </param>
		/// <param name="t1"> The translational component of the matrix
		/// </param>
		/// <param name="s"> The scale value applied to the rotational components
		/// </param>
		public Matrix4f(Quat4f q1, Vector3f t1, float s)
		{
			set_Renamed(q1, t1, s);
		}
Example #19
0
		/// <summary> Transforms the normal parameter by this transform and places the value
		/// back into normal.  The fourth element of the normal is assumed to be zero.
		/// </summary>
		/// <param name="normal">the input normal to be transformed.
		/// </param>
		public void  transform(Vector3f normal)
		{
			transform(normal, normal);
		}
Example #20
0
		/// <summary> Transforms the normal parameter by this Matrix4f and places the value
		/// into normalOut.  The fourth element of the normal is assumed to be zero.
		/// </summary>
		/// <param name="normal">the input normal to be transformed.
		/// </param>
		/// <param name="normalOut">the transformed normal
		/// </param>
		public void  transform(Vector3f normal, Vector3f normalOut)
		{
			normalOut.set_Renamed(m00 * normal.x + m01 * normal.y + m02 * normal.z, m10 * normal.x + m11 * normal.y + m12 * normal.z, m20 * normal.x + m21 * normal.y + m22 * normal.z);
		}
Example #21
0
		/// <summary> Sets the value of this matrix to a scale and translation matrix;
		/// the translation is scaled by the scale factor and all of the
		/// matrix values are modified.
		/// </summary>
		/// <param name="v1">the translation amount
		/// </param>
		/// <param name="scale">the scale factor for the matrix
		/// </param>
		public void  set_Renamed(Vector3f v1, float scale)
		{
			m00 = scale; m01 = 0.0f; m02 = 0.0f; m03 = scale * v1.x;
			m10 = 0.0f; m11 = scale; m12 = 0.0f; m13 = scale * v1.y;
			m20 = 0.0f; m21 = 0.0f; m22 = scale; m23 = scale * v1.z;
			m30 = 0.0f; m31 = 0.0f; m32 = 0.0f; m33 = 1.0f;
		}
Example #22
0
		/// <summary> Sets the value of this matrix to a translate matrix by the
		/// passed translation value.
		/// </summary>
		/// <param name="v1">the translation amount
		/// </param>
		public void  set_Renamed(Vector3f v1)
		{
			setIdentity();
			setTranslation(v1);
		}
Example #23
0
		/// <summary> Sets the value of this matrix to a scale and translation matrix;
		/// scale is not applied to the translation and all of the matrix
		/// values are modified.
		/// </summary>
		/// <param name="scale">the scale factor for the matrix
		/// </param>
		/// <param name="v1">the translation amount
		/// </param>
		public void  set_Renamed(float scale, Vector3f v1)
		{
			set_Renamed(scale);
			setTranslation(v1);
		}
Example #24
0
		/// <summary> Sets the value of this vector to the normalization of vector v1.</summary>
		/// <param name="v1">the un-normalized vector
		/// </param>
		public void  normalize(Vector3f v1)
		{
			set_Renamed(v1);
			normalize();
		}
Example #25
0
        public void transformPoint(Point3f pointAngstroms, Vector3f vibrationVector, Point3i pointScreen)
		{
            //transformManager.transformPoint(pointAngstroms, vibrationVector, pointScreen);
		}
Example #26
0
		/// <summary> Sets the value of this matrix from the rotation expressed by the
		/// rotation matrix m1, the translation t1, and the scale s. The translation
		/// is not modified by the scale.
		/// </summary>
		/// <param name="m1">The rotation component
		/// </param>
		/// <param name="t1">The translation component
		/// </param>
		/// <param name="scale">The scale component
		/// </param>
		public void  set_Renamed(Matrix3f m1, Vector3f t1, float scale)
		{
			setRotationScale(m1);
			mulRotationScale(scale);
			setTranslation(t1);
			m33 = 1.0f;
		}
Example #27
0
		/// <summary> Sets this vector to be the vector cross product of vectors v1 and v2.</summary>
		/// <param name="v1">the first vector
		/// </param>
		/// <param name="v2">the second vector
		/// </param>
		public void  cross(Vector3f v1, Vector3f v2)
		{
			// store in tmp once for aliasing-safty
			// i.e. safe when a.cross(a, b)
			set_Renamed(v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x);
		}
Example #28
0
		/// <summary> Sets the value of this matrix from the rotation expressed by the
		/// quaternion q1, the translation t1, and the scale s.
		/// </summary>
		/// <param name="q1"> the rotation expressed as a quaternion
		/// </param>
		/// <param name="t1"> the translation
		/// </param>
		/// <param name="s"> the scale value
		/// </param>
		public void  set_Renamed(Quat4f q1, Vector3f t1, float s)
		{
			set_Renamed(q1);
			mulRotationScale(s);
			m03 = t1.x;
			m13 = t1.y;
			m23 = t1.z;
		}
Example #29
0
        public virtual void calcSheetUnitVectors()
		{
			if (widthUnitVector == null)
			{
				Vector3f vectorCO = new Vector3f();
				Vector3f vectorCOSum = new Vector3f();
				AminoMonomer amino = (AminoMonomer) aminoPolymer.monomers[monomerIndex];
				vectorCOSum.sub(amino.CarbonylOxygenAtomPoint, amino.CarbonylCarbonAtomPoint);
				for (int i = monomerCount; --i > 0; )
				{
					amino = (AminoMonomer) aminoPolymer.monomers[i];
					vectorCO.sub(amino.CarbonylOxygenAtomPoint, amino.CarbonylCarbonAtomPoint);
					//UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
					if (vectorCOSum.angle(vectorCO) < (float) System.Math.PI / 2)
						vectorCOSum.add(vectorCO);
					else
						vectorCOSum.sub(vectorCO);
				}
				heightUnitVector = vectorCO; // just reuse the same temp vector;
				heightUnitVector.cross(axisUnitVector, vectorCOSum);
				heightUnitVector.normalize();
				widthUnitVector = vectorCOSum;
				widthUnitVector.cross(axisUnitVector, heightUnitVector);
			}
		}
Example #30
0
		/// <summary> Computes the dot product of the this vector and vector v1.</summary>
		/// <param name="v1">the other vector
		/// </param>
		public float dot(Vector3f v1)
		{
			return x * v1.x + y * v1.y + z * v1.z;
		}