Example #1
0
        public static VectorF Rotate(this VectorF v, double phi)
        {
            float newX = (float)((double)v.X * Math.Cos(phi) - (double)v.Y * Math.Sin(phi));
            float newY = (float)((double)v.X * Math.Sin(phi) + (double)v.Y * Math.Cos(phi));

            return(new VectorF(newX, newY));
        }
Example #2
0
        public StraightLineF(PointF pointF, VectorF normalVectorF)
        {
            //A*x + B*y = A * x_0 + B * y_0
            var unitVectorF = normalVectorF.UnitVector();

            A = unitVectorF.X;
            B = unitVectorF.Y;
            C = -(A * pointF.X + B * pointF.Y);
        }
Example #3
0
        public StraightLineF(PointF from, PointF to)
        {
            var dirVectorF    = new VectorF(from, to);
            var normalVectorF = dirVectorF.Rotate(Math.PI / 2.0);
            var unitVectorF   = normalVectorF.UnitVector();

            A = unitVectorF.X;
            B = unitVectorF.Y;
            C = -(A * from.X + B * from.Y);
        }
Example #4
0
 public static double Length(this VectorF v)
 {
     return(Math.Sqrt((double)(v.X * v.X + v.Y * v.Y)));
 }
Example #5
0
 public static VectorF Multiply(this VectorF v, double lambda)
 {
     return(v.Multiply((float)lambda));
 }
Example #6
0
 public static VectorF Multiply(this VectorF v, float lambda)
 {
     return(new VectorF(v.X * lambda, v.Y * lambda));
 }
Example #7
0
        public static VectorF UnitVector(this VectorF v)
        {
            float length = (float)v.Length();

            return(new VectorF(v.X / length, v.Y / length));
        }