public static PVector Add(PVector v1, PVector v2) { var v = v1.CopyVector(); v1.Add(v2); return(v1); }
public static PVector Sub(PVector v1, PVector v2) { var v = v1.CopyVector(); v.Sub(v2); return(v); }
public PVector ProjectTo(PVector vec) { var v = vec.CopyVector(); v.Normalize(); v.Mult(Dot(vec)); return(v); }
public static PVector Rotate3D(PVector vector, PVector axis, double theta) { var vec = axis.CopyVector(); vec.Normalize(); double scalar_1 = (1 - Math.Cos(theta)) * (Dot(vector, vec)); double scalar_2 = Math.Cos(theta); double scalar_3 = Math.Sin(theta); PVector norm = vec.CopyVector(); PVector tv = vector.CopyVector(); PVector crs = Cross(norm, tv); norm.Mult(scalar_1); tv.Mult(scalar_2); crs.Mult(scalar_3); var retVal = norm.CopyVector(); retVal.Add(tv); retVal.Add(crs); return(retVal); }
public static PCurve GetNodeCurve(PVector pt1, PVector pt2) { var p1 = pt1.CopyVector(); p1.Z = 0; var p2 = pt2.CopyVector(); p2.Z = 0; var wdif = Math.Abs(p2.X - p1.X) / 2; if (wdif < 50) { wdif = 50; } PVector p1A = new PVector(p1.X + wdif, p1.Y); PVector p2A = new PVector(p2.X - wdif, p2.Y); var ls = new List <PVector>() { p1, p1A, p2A, p2 }; return(new PCurve(ls)); }