Exemple #1
0
        static public IGrid <T> Circle <T>(int radius, Operation <T, float> operation)
        {
            int      diameter = radius * 2;
            VectorF2 center   = new VectorF2(radius, radius);

            return(Operation <T>(diameter, diameter,
                                 (x, y) => operation(center.GetDistanceTo(new VectorF2(x, y)) / radius)
                                 ));
        }
Exemple #2
0
        static public float CalculateTriangleShortestToLongestSideRatio(this VectorF2 point1, VectorF2 point2, VectorF2 point3)
        {
            float a;
            float b;
            float c;

            point1.GetDistanceTo(point2).Order(
                point2.GetDistanceTo(point3),
                point3.GetDistanceTo(point1),
                out c, out b, out a
                );

            return(c / a);
        }
Exemple #3
0
        static public float CalculateTriangleArea(this VectorF2 point1, VectorF2 point2, VectorF2 point3)
        {
            float a;
            float b;
            float c;

            point1.GetDistanceTo(point2).Order(
                point2.GetDistanceTo(point3),
                point3.GetDistanceTo(point1),
                out c, out b, out a
                );

            float ab = a - b;

            float t1 = a + (b + c);
            float t2 = c - ab;
            float t3 = c + ab;
            float t4 = a + (b - c);

            return(0.25f * Mathq.Sqrt(t1 * t2 * t3 * t4));
        }
Exemple #4
0
 static public VectorF2 GetPointNearLine(this VectorF2 item, VectorF2 target, float distance, float offset)
 {
     return(item.GetPointNearLineByPercent(target, distance / item.GetDistanceTo(target), offset));
 }
Exemple #5
0
 static public VectorF2 GetPointOnLineSegment(this VectorF2 item, VectorF2 target, float distance)
 {
     return(item.GetPointOnLineSegmentByPercent(target, distance / item.GetDistanceTo(target)));
 }