示例#1
0
        static public bool TryGetTriangleCoplanarEdge(this Plane item, Triangle3 triangle, float tolerance, out LineSegment3 edge)
        {
            bool is_v0_near = item.GetAbsoluteDistanceToPoint(triangle.v0) <= tolerance;
            bool is_v1_near = item.GetAbsoluteDistanceToPoint(triangle.v1) <= tolerance;
            bool is_v2_near = item.GetAbsoluteDistanceToPoint(triangle.v2) <= tolerance;

            if (is_v0_near && is_v1_near && is_v2_near == false)
            {
                edge = triangle.GetEdge01();
                return(true);
            }

            if (is_v1_near && is_v2_near && is_v0_near == false)
            {
                edge = triangle.GetEdge12();
                return(true);
            }

            if (is_v2_near && is_v0_near && is_v1_near == false)
            {
                edge = triangle.GetEdge20();
                return(true);
            }

            edge = default(LineSegment3);
            return(false);
        }
示例#2
0
        static public Vector3 GetPointOnEdgeByPercent(this Triangle3 item, float percent)
        {
            percent = percent.GetLooped(3.0f);

            if (percent < 1.0f)
            {
                return(item.GetEdge01().GetPointOnByPercent(percent));
            }

            if (percent < 2.0f)
            {
                return(item.GetEdge12().GetPointOnByPercent(percent - 1.0f));
            }

            return(item.GetEdge20().GetPointOnByPercent(percent - 2.0f));
        }