public static double AngleBetweenVectors(this IMathVector v0, IMathVector v1) { if (((double[])v0.ArrayData).Length == ((double[])v1.ArrayData).Length) { var sign = Math.Sign(((IMathVector)(v0.Cross(v1))).ArrayData.CastArray <double>()[2]); var ret = Math.Acos(v0.Dot(v1) / (v0.GetLength() * v1.GetLength())); return(sign * ret); } throw new Exception("Vectors must have the same dimension!"); }
public IMathTransform GetTransformBetweenVectorsAroundPoint( double[] vec1, double[] vec2, double[] pt) { IMathVector mathVec1 = m_MathUtils.CreateVector(vec1) as IMathVector; IMathVector mathVec2 = m_MathUtils.CreateVector(vec2) as IMathVector; IMathVector crossVec = mathVec1.Cross(mathVec2) as IMathVector; double dot = mathVec1.Dot(mathVec2); double vec1Len = mathVec1.GetLength(); double vec2Len = mathVec2.GetLength(); double angle = Math.Acos(dot / vec1Len * vec2Len); IMathPoint mathPt = m_MathUtils.CreatePoint(pt) as IMathPoint; return(m_MathUtils.CreateTransformRotateAxis(mathPt, crossVec, angle) as IMathTransform); }
public TransformationMaxtrix GetTransformBetweenVectorsAroundPoint( Vector firstVector, Vector secondVector, Point point) { IMathVector mathVec1 = (m_MathUtils.CreateVector(firstVector.ToArray()) as IMathVector).Normalise(); IMathVector mathVec2 = (m_MathUtils.CreateVector(secondVector.ToArray()) as IMathVector).Normalise(); IMathVector crossVec = (mathVec1.Cross(mathVec2) as IMathVector).Normalise(); double dot = mathVec1.Dot(mathVec2); double vec1Len = mathVec1.GetLength(); double vec2Len = mathVec2.GetLength(); double angle = System.Math.Acos(dot / vec1Len * vec2Len); IMathPoint mathPt = m_MathUtils.CreatePoint(point.ToArray()) as IMathPoint; var mathTransform = m_MathUtils.CreateTransformRotateAxis(mathPt, crossVec, angle) as IMathTransform; return(mathTransform.ToTransformationMaxtrix()); }
private double GetAngle(IMathVector vec1, IMathVector vec2) { return(Math.Acos(vec1.Dot(vec2) / (vec1.GetLength() * vec2.GetLength()))); }
public static double AngleBetweenVectors(this IMathVector v0, IMathVector v1) { if (((double[])v0.ArrayData).Length==((double[])v1.ArrayData).Length) { var sign = Math.Sign(((IMathVector)(v0.Cross(v1))).ArrayData.CastArray<double>()[2]); var ret = Math.Acos(v0.Dot(v1) / (v0.GetLength() * v1.GetLength())); return sign * ret; } throw new Exception("Vectors must have the same dimension!"); }
public static double GetAngle(this IMathVector vec1, IMathVector vec2) { return(Math.Acos(vec1.Dot(vec2) / (vec1.GetLength() * vec2.GetLength()))); }