public static Vector3D Cross(Vector3D a, Vector3D b) { Vector3D cross = new Vector3D(a.Y * b.Z - a.Z * b.Y, a.Z * b.X - a.X * b.Z, a.X * b.Y - a.Y * b.X); return cross; }
public Vertex(Vector3D position, Vector3D normal, Vector4D tangent, UV uv1, UV uv2, Color4 color) { Position = position; Normal = normal; Tangent = tangent; UV1 = uv1; UV2 = uv2; Color = color; }
public Vertex(Vertex vertex) { Position = vertex.Position; Normal = vertex.Normal; Tangent = vertex.Tangent; UV1 = vertex.UV1; UV2 = vertex.UV2; Color = vertex.Color; }
public static Plane BuildFromVertices(Vector3D a, Vector3D b, Vector3D c) { Plane p = new Plane (); Vector3D edgeA = c.SubtractedBy (a); Vector3D edgeB = b.SubtractedBy (a); Vector3D cross = edgeA.Cross (edgeB); // !! Important: inverted to be valid in left-handed space // TODO: make this work in either handed-ness automatically cross.Invert(); p.Normal = cross.Normalized(); p.D = p.Normal.Dot (a); return p; }
public Plane(Vector3D normal, float d) { Normal = normal; D = d; }
public static float Dot(Vector3D a, Vector3D b) { return a.X * b.X + a.Y * b.Y + a.Z * b.Z; }
public Vector3D Inverted() { Vector3D inverted = new Vector3D(this); inverted.Invert (); return inverted; }
public Vector3D Lerped(Vector3D dest, float t) { return new Vector3D(this).AddedWith(dest.SubtractedBy (this).MultipliedBy (t)); }
public Vector3D Cross(Vector3D b) { return Cross (this, b); }
public float Dot(Vector3D b) { return Dot (this, b); }
public void Add(Vector3D b) { this.X += b.X; this.Y += b.Y; this.Z += b.Z; }
public Vector3D AddedWith(Vector3D b) { Vector3D added = new Vector3D (this); added.Add (b); return added; }
public Vector3D MultipliedBy(float factor) { Vector3D multiplied = new Vector3D(this); multiplied.MultiplyBy (factor); return multiplied; }
public Vector3D Normalized() { Vector3D normalized = new Vector3D(this); normalized.Normalize (); return normalized; }
public Vector3D(Vector3D src) { X = src.X; Y = src.Y; Z = src.Z; }
public Vector3D SubtractedBy(Vector3D b) { Vector3D subtracted = new Vector3D (this); subtracted.Subtract (b); return subtracted; }
public void Subtract(Vector3D b) { this.X -= b.X; this.Y -= b.Y; this.Z -= b.Z; }