Пример #1
0
        public int LexicalCompare(Ray2d other)
        {
            var cmp = Origin.LexicalCompare(other.Origin);

            if (cmp != 0)
            {
                return(cmp);
            }
            return(Direction.LexicalCompare(other.Direction));
        }
Пример #2
0
        public V2d Intersect(Ray2d r)
        {
            V2d a = r.Origin - Origin;

            if (a.Abs().AllSmaller(Constant <double> .PositiveTinyValue))
            {
                return(Origin); // Early exit when rays have same origin
            }
            double cross = Direction.Dot270(r.Direction);

            if (!Fun.IsTiny(cross)) // Rays not parallel
            {
                return(Origin + Direction * r.Direction.Dot90(a) / cross);
            }
            else // Rays are parallel
            {
                return(V2d.NaN);
            }
        }
Пример #3
0
 public static bool IsParallelTo(this Ray2d ray, V2d v, double epsilon = 1e-6)
 => ray.Direction.IsParallelTo(v, epsilon);
Пример #4
0
 public static bool IsParallelTo(this Ray2d ray, V2d v)
 => ray.Direction.IsParallelTo(v);
Пример #5
0
 public static bool IsOrthogonalTo(this Ray2d r0, Ray2d r1) => r0.Direction.IsOrthogonalTo(r1.Direction);
Пример #6
0
 public static bool IsOrthogonalTo(this Ray2d ray, V2d v) => ray.Direction.IsOrthogonalTo(v);
Пример #7
0
 public FastRay2d(Ray2d ray)
 {
     Ray      = ray;
     DirFlags = ray.Direction.DirFlags();
     InvDir   = 1.0 / ray.Direction;
 }
Пример #8
0
 public static bool ApproximateEquals(this Ray2d a, Ray2d b)
 => ApproximateEquals(a, b, Constant <double> .PositiveTinyValue);
Пример #9
0
 public static bool IsOrthogonalTo(this Ray2d r0, Ray2d r1)
 {
     return(r0.Direction.IsOrthogonalTo(r1.Direction));
 }
Пример #10
0
 public bool Equals(Ray2d other)
 => Origin.Equals(other.Origin) && Direction.Equals(other.Direction);
Пример #11
0
 public double AngleBetween(Ray2d r)
 => Direction.AngleBetween(r.Direction);
Пример #12
0
 public static bool IsParallelTo(this Ray2d r0, Ray2d r1)
 {
     return(r0.Direction.IsParallelTo(r1.Direction));
 }
Пример #13
0
 public static bool IsParallelTo(this Ray2d ray, V2d v)
 {
     return(ray.Direction.IsParallelTo(v));
 }
Пример #14
0
 public static bool IsParallelTo(this Ray2d r0, Ray2d r1)
 => r0.Direction.IsParallelTo(r1.Direction);
Пример #15
0
 public static bool ApproximateEquals(this Ray2d a, Ray2d b, double tolerance) =>
 ApproximateEquals(a.Origin, b.Origin, tolerance) &&
 ApproximateEquals(a.Direction, b.Direction, tolerance);
Пример #16
0
 public static bool IsParallelTo(this Ray2d r0, Ray2d r1, double epsilon = 1e-6)
 => r0.Direction.IsParallelTo(r1.Direction, epsilon);
Пример #17
0
 public static bool IsOrthogonalTo(this Ray2d ray, V2d v)
 {
     return(ray.Direction.IsOrthogonalTo(v));
 }