public SubtractedBy ( |
||
b | ||
return |
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 static void BuildFromVertices(Vector3D a, Vector3D b, Vector3D c, Plane outPlane) { Vector3D edgeA = c.SubtractedBy(a, tempVectorA); Vector3D edgeB = b.SubtractedBy(a, tempVectorB); Vector3D cross = edgeA.Cross(edgeB, tempVectorC); // !! Important: inverted to be valid in left-handed space // TODO: make this work in either handed-ness automatically cross.Invert(); outPlane.Normal.Copy(cross); outPlane.Normal.Normalize(); outPlane.D = outPlane.Normal.Dot(a); float padding = 0.15f; outPlane.PlaneBounds.min.X = Mathf.Min(a.X, b.X, c.X) - padding; outPlane.PlaneBounds.min.Y = Mathf.Min(a.Y, b.Y, c.Y) - padding; outPlane.PlaneBounds.min.Z = Mathf.Min(a.Z, b.Z, c.Z) - padding; outPlane.PlaneBounds.max.X = Mathf.Max(a.X, b.X, c.X) + padding; outPlane.PlaneBounds.max.Y = Mathf.Max(a.Y, b.Y, c.Y) + padding; outPlane.PlaneBounds.max.Z = Mathf.Max(a.Z, b.Z, c.Z) + padding; }
public Vector3D Lerped(Vector3D dest, float t) { return new Vector3D(this).AddedWith(dest.SubtractedBy (this).MultipliedBy (t)); }