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)); }
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); }
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); }
public static double Length(this VectorF v) { return(Math.Sqrt((double)(v.X * v.X + v.Y * v.Y))); }
public static VectorF Multiply(this VectorF v, double lambda) { return(v.Multiply((float)lambda)); }
public static VectorF Multiply(this VectorF v, float lambda) { return(new VectorF(v.X * lambda, v.Y * lambda)); }
public static VectorF UnitVector(this VectorF v) { float length = (float)v.Length(); return(new VectorF(v.X / length, v.Y / length)); }