示例#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));
 }