public static bool IsPlaneIntersectingCone(Vect3 planeNormal, Vect3 planePoint, Vect3 conePosition, Vect3 coneAxis, double coneAxisLength, double coneCosPhi) { double len; //try "bending" axis towards plane normal Vect3 q = conePosition + coneAxis * coneAxisLength; Vect3 qx = planeNormal.ProjectOn(coneAxis); Vect3 p = qx - planeNormal; if (System.Math.Abs(p.QuadLength() - 0) < Constants.EPS) { // axis equals plane normal p = coneAxis; len = coneAxisLength; } else { //bend axis towards plane normal as far as sinPhi allows p = p.Normalize(); q = q + (p * coneAxisLength * System.Math.Sin(System.Math.Acos(coneCosPhi))); q -= conePosition; len = q.Length(); p = q / len; } double d = RayPlane.GetHitPointRayPlaneDistance(conePosition, p, planePoint, planeNormal); return(d < len); }
/** * Reflects the incoming vector on the axis (must be normed). * * @param incoming incoming vector * @param normal normal of the reflectio area * @param outgoing result of the computation */ public static Vect3 ReflectOn(this Vect3 incoming, Vect3 normal) { Vect3 result = incoming.ProjectOn(normal); result = result * -2; return(incoming + result); }
public static bool IsAreaIntersectingCone(Vect3 planeNormal, Vect3 planePoint, double areaWidthHalf, Vect3 conePosition, Vect3 coneAxis, double coneAxisLength, double coneCosPhi) { double len; //try "bending" axis towards plane normal Vect3 q = conePosition + coneAxis * coneAxisLength; Vect3 qx = planeNormal.ProjectOn(coneAxis); Vect3 p = qx - planeNormal; if (System.Math.Abs(p.QuadLength() - 0) < Constants.EPS) { // axis equals plane normal p = coneAxis; len = coneAxisLength; } else { //bend axis towards plane normal as far as sinPhi allows p = p.Normalize(); q = q + (p * coneAxisLength * System.Math.Sin(System.Math.Acos(coneCosPhi))); q -= conePosition; len = q.Length(); p = q / len; } double d = RayPlane.GetHitPointRayPlaneDistance(conePosition, p, planePoint, planeNormal); if (d < len) { //check if Hitpoint is in the +/-width/2 - area of the plane p = conePosition + p * d; return (System.Math.Abs(p.X - planePoint.X) < areaWidthHalf * 2 && System.Math.Abs(p.Y - planePoint.Y) < areaWidthHalf * 2 && System.Math.Abs(p.Z - planePoint.Z) < areaWidthHalf * 2); } return(false); }
public static double InterpolateTriangleEdge(Vect3 v1, Vect3 v2, Vect3 v3, Vect3 point) { Vect3 v23N = v3 - v2; v23N = v23N.Normalize(); Vect3 v21 = v1 - v2; // ReSharper disable InconsistentNaming Vect3 v1o = v21.ProjectOn(v23N); //punkt gegenüber der ecke v1 (o ... opposite) // ReSharper restore InconsistentNaming v1o -= v21; double h1 = v1o.Length(); //höhe auf v1 v1o = v1o / h1; //normieren Vect3 v1P = point - v1; Vect3 p1 = v1P.ProjectOn(v1o); //projektion von v1p auf v1hn return(1 - (p1.Length() / h1)); }