/// <summary> /// Returns the aspect ratio of the tetrahedra defined by 4 given points. /// This is defined as the longest edge / shortest altitude. /// </summary> /// <param name="points"></param> /// <returns></returns> public static double GetTetraAspect(Vec3d p0, Vec3d p1, Vec3d p2, Vec3d p3) { double minEdge = 0.0; double maxAlt = double.PositiveInfinity; Vec3d v0 = p1 - p0; Vec3d v1 = p2 - p1; Vec3d v2 = p3 - p2; Vec3d v3 = p0 - p3; Sub(v0, v1, v2); Sub(v1, v2, v3); Sub(v2, v3, v0); Sub(v3, v0, v1); return(Math.Sqrt(minEdge) / Math.Sqrt(maxAlt)); void Sub(Vec3d a, Vec3d b, Vec3d c) { minEdge = Math.Max(minEdge, a.SquareLength); maxAlt = Math.Min(maxAlt, Vec3d.Project(c, Vec3d.Cross(a, b)).SquareLength); } }
/// <summary> /// /// </summary> /// <param name="point"></param> /// <param name="origin"></param> /// <param name="normal"></param> /// <returns></returns> public static Vec3d ProjectToPlane(Vec3d point, Vec3d origin, Vec3d normal) { return(point + Vec3d.Project(origin - point, normal)); }
/// <summary> /// /// </summary> /// <param name="point"></param> /// <param name="origin"></param> /// <param name="normal"></param> /// <returns></returns> public static Vec3d ReflectInPlane(Vec3d point, Vec3d origin, Vec3d normal) { return(point + Vec3d.Project(origin - point, normal) * 2.0); }