예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="vector"></param>
        /// <returns></returns>
        public static Color ToColor(this Vec3d vector)
        {
            int r = SlurMath.Clamp((int)vector.X, 255);
            int g = SlurMath.Clamp((int)vector.Y, 255);
            int b = SlurMath.Clamp((int)vector.Z, 255);

            return(Color.FromArgb(r, g, b));
        }
예제 #2
0
        /// <summary>
        /// Returns the angle between two vectors.
        /// If either vector is zero length, Double.NaN is returned.
        /// </summary>
        /// <param name="v0"></param>
        /// <param name="v1"></param>
        /// <returns></returns>
        public static double Angle(Vec4d v0, Vec4d v1)
        {
            double d = v0.SquareLength * v1.SquareLength;

            if (d > 0.0)
            {
                return(Math.Acos(SlurMath.Clamp(Dot(v0, v1) / Math.Sqrt(d), -1.0, 1.0))); // clamp dot product to remove noise
            }
            return(double.NaN);
        }
예제 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="t"></param>
 /// <returns></returns>
 public double Clamp(double t)
 {
     if (IsDecreasing)
     {
         return(SlurMath.Clamp(t, B, A));
     }
     else
     {
         return(SlurMath.Clamp(t, A, B));
     }
 }
예제 #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="t"></param>
 /// <returns></returns>
 public double Clamp(double t)
 {
     if (IsDecreasing)
     {
         return(SlurMath.Clamp(t, T1, T0));
     }
     else
     {
         return(SlurMath.Clamp(t, T0, T1));
     }
 }
예제 #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="t"></param>
 /// <returns></returns>
 public float Clamp(float t)
 {
     if (IsDecreasing)
     {
         return(SlurMath.Clamp(t, B, A));
     }
     else
     {
         return(SlurMath.Clamp(t, A, B));
     }
 }