Ejemplo n.º 1
0
        public int LexicalCompare(Ray2d other)
        {
            var cmp = Origin.LexicalCompare(other.Origin);

            if (cmp != 0)
            {
                return(cmp);
            }
            return(Direction.LexicalCompare(other.Direction));
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 3
0
 public static bool IsParallelTo(this Ray2d ray, V2d v, double epsilon = 1e-6)
 => ray.Direction.IsParallelTo(v, epsilon);
Ejemplo n.º 4
0
 public static bool IsParallelTo(this Ray2d ray, V2d v)
 => ray.Direction.IsParallelTo(v);
Ejemplo n.º 5
0
 public static bool IsOrthogonalTo(this Ray2d r0, Ray2d r1) => r0.Direction.IsOrthogonalTo(r1.Direction);
Ejemplo n.º 6
0
 public static bool IsOrthogonalTo(this Ray2d ray, V2d v) => ray.Direction.IsOrthogonalTo(v);
Ejemplo n.º 7
0
 public FastRay2d(Ray2d ray)
 {
     Ray      = ray;
     DirFlags = ray.Direction.DirFlags();
     InvDir   = 1.0 / ray.Direction;
 }
Ejemplo n.º 8
0
 public static bool ApproximateEquals(this Ray2d a, Ray2d b)
 => ApproximateEquals(a, b, Constant <double> .PositiveTinyValue);
Ejemplo n.º 9
0
 public static bool IsOrthogonalTo(this Ray2d r0, Ray2d r1)
 {
     return(r0.Direction.IsOrthogonalTo(r1.Direction));
 }
Ejemplo n.º 10
0
 public bool Equals(Ray2d other)
 => Origin.Equals(other.Origin) && Direction.Equals(other.Direction);
Ejemplo n.º 11
0
 public double AngleBetween(Ray2d r)
 => Direction.AngleBetween(r.Direction);
Ejemplo n.º 12
0
 public static bool IsParallelTo(this Ray2d r0, Ray2d r1)
 {
     return(r0.Direction.IsParallelTo(r1.Direction));
 }
Ejemplo n.º 13
0
 public static bool IsParallelTo(this Ray2d ray, V2d v)
 {
     return(ray.Direction.IsParallelTo(v));
 }
Ejemplo n.º 14
0
 public static bool IsParallelTo(this Ray2d r0, Ray2d r1)
 => r0.Direction.IsParallelTo(r1.Direction);
Ejemplo n.º 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);
Ejemplo n.º 16
0
 public static bool IsParallelTo(this Ray2d r0, Ray2d r1, double epsilon = 1e-6)
 => r0.Direction.IsParallelTo(r1.Direction, epsilon);
Ejemplo n.º 17
0
 public static bool IsOrthogonalTo(this Ray2d ray, V2d v)
 {
     return(ray.Direction.IsOrthogonalTo(v));
 }