Example #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="v0"></param>
 /// <param name="v1"></param>
 /// <param name="angle"></param>
 /// <param name="factor"></param>
 /// <returns></returns>
 public static Vec3d Slerp(Vec3d v0, Vec3d v1, double angle, double factor)
 {
     return(v0.SlerpTo(v1, angle, factor));
 }
Example #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="v0"></param>
 /// <param name="v1"></param>
 /// <param name="factor"></param>
 /// <returns></returns>
 public static Vec3d Lerp(Vec3d v0, Vec3d v1, double factor)
 {
     return(v0.LerpTo(v1, factor));
 }
Example #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="v0"></param>
 /// <param name="v1"></param>
 /// <param name="factor"></param>
 /// <returns></returns>
 public static Vec3d Slerp(Vec3d v0, Vec3d v1, double factor)
 {
     return(v0.SlerpTo(v1, Angle(v0, v1), factor));
 }
Example #4
0
 /// <summary>
 /// Returns a vector parallel to v0 whos projection onto v1 equals v1
 /// </summary>
 /// <param name="v0"></param>
 /// <param name="v1"></param>
 /// <returns></returns>
 public static Vec3d MatchProjection(Vec3d v0, Vec3d v1)
 {
     return(v1.SquareLength / Dot(v0, v1) * v0);
 }
Example #5
0
 /// <summary>
 /// Returns a vector parallel to v0 whose projection onto v2 equals the projection of v1 onto v2
 /// </summary>
 /// <param name="v0"></param>
 /// <param name="v1"></param>
 /// <param name="v2"></param>
 /// <returns></returns>
 public static Vec3d MatchProjection(Vec3d v0, Vec3d v1, Vec3d v2)
 {
     return(Dot(v1, v2) / Dot(v0, v2) * v0);
 }
Example #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="v0"></param>
 /// <param name="v1"></param>
 /// <returns></returns>
 public static Vec3d Min(Vec3d v0, Vec3d v1)
 {
     return(new Vec3d(Math.Min(v0.X, v1.X), Math.Min(v0.Y, v1.Y), Math.Min(v0.Z, v1.Z)));
 }
Example #7
0
 /// <summary>
 /// Returns the reflection of v0 about v1.
 /// </summary>
 /// <param name="v0"></param>
 /// <param name="v1"></param>
 /// <returns></returns>
 public static Vec3d Reflect(Vec3d v0, Vec3d v1)
 {
     //return Project(v0, v1) * 2.0 - v0;
     return(v1 * (Dot(v0, v1) / v1.SquareLength * 2.0) - v0);
 }
Example #8
0
 /// <summary>
 /// Returns the cotangent of the angle between 2 vectors as per http://www.cs.columbia.edu/~keenan/Projects/Other/TriangleAreasCheatSheet.pdf.
 /// </summary>
 /// <param name="v0"></param>
 /// <param name="v1"></param>
 /// <returns></returns>
 public static double Cotangent(Vec3d v0, Vec3d v1)
 {
     return(Dot(v0, v1) / Cross(v0, v1).Length);
 }
Example #9
0
 /// <summary>
 /// Returns the projection of v0 onto v1.
 /// </summary>
 /// <param name="v0"></param>
 /// <param name="v1"></param>
 /// <returns></returns>
 public static Vec3d Project(Vec3d v0, Vec3d v1)
 {
     return(Dot(v0, v1) / v1.SquareLength * v1);
 }
Example #10
0
        /// <summary>
        /// Returns the minimum angle between two vectors.
        /// </summary>
        /// <param name="v0"></param>
        /// <param name="v1"></param>
        /// <returns></returns>
        public static double Angle(Vec3d v0, Vec3d v1)
        {
            var d = v0.SquareLength * v1.SquareLength;

            return(d > 0.0 ? zMath.AcosSafe(Dot(v0, v1) / Math.Sqrt(d)) : 0.0);
        }
Example #11
0
        /// <summary>
        /// Returns the signed angle between two vectors.
        /// </summary>
        /// <param name="v0"></param>
        /// <param name="v1"></param>
        /// <returns></returns>
        public static double SignedAngle(Vec3d v0, Vec3d v1, Vec3d up)
        {
            var c = Cross(v0, v1);

            return(Math.Atan2(c.Length * Math.Sign(Dot(c, up)), Dot(v0, v1)));
        }
Example #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="v0"></param>
 /// <param name="v1"></param>
 /// <returns></returns>
 public static double AbsDot(Vec3d v0, Vec3d v1)
 {
     return(Math.Abs(v0.X * v1.X) + Math.Abs(v0.Y * v1.Y) + Math.Abs(v0.Z * v1.Z));
 }
Example #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="v0"></param>
 /// <param name="v1"></param>
 /// <returns></returns>
 public static double Dot(Vec3d v0, Vec3d v1)
 {
     return(v0.X * v1.X + v0.Y * v1.Y + v0.Z * v1.Z);
 }
Example #14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="vector"></param>
 /// <returns></returns>
 public static Vec3d Abs(Vec3d vector)
 {
     return(new Vec3d(Math.Abs(vector.X), Math.Abs(vector.Y), Math.Abs(vector.Z)));
 }
Example #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="v0"></param>
 /// <param name="v1"></param>
 /// <param name="factor"></param>
 /// <returns></returns>
 public Vec3d SlerpTo(Vec3d other, double factor)
 {
     return(SlerpTo(other, Angle(this, other), factor));
 }
Example #16
0
 /// <summary>
 /// Returns the rejection of v0 onto v1.
 /// This is the perpendicular component of v0 with respect to v1.
 /// </summary>
 /// <param name="v0"></param>
 /// <param name="v1"></param>
 /// <returns></returns>
 public static Vec3d Reject(Vec3d v0, Vec3d v1)
 {
     return(v0 - Project(v0, v1));
 }
Example #17
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rotation"></param>
 /// <param name="point"></param>
 /// <returns></returns>
 public static Orient3d CreateRotationAtPoint(AxisAngle3d rotation, Vec3d point)
 {
     throw new NotImplementedException();
 }
Example #18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="v"></param>
 /// <param name="t"></param>
 /// <returns></returns>
 public static Vec3d Min(Vec3d v, double t)
 {
     return(new Vec3d(Math.Min(v.X, t), Math.Min(v.Y, t), Math.Min(v.Z, t)));
 }