public int LexicalCompare(Ray2d other) { var cmp = Origin.LexicalCompare(other.Origin); if (cmp != 0) { return(cmp); } return(Direction.LexicalCompare(other.Direction)); }
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); } }
public static bool IsParallelTo(this Ray2d ray, V2d v, double epsilon = 1e-6) => ray.Direction.IsParallelTo(v, epsilon);
public static bool IsParallelTo(this Ray2d ray, V2d v) => ray.Direction.IsParallelTo(v);
public static bool IsOrthogonalTo(this Ray2d r0, Ray2d r1) => r0.Direction.IsOrthogonalTo(r1.Direction);
public static bool IsOrthogonalTo(this Ray2d ray, V2d v) => ray.Direction.IsOrthogonalTo(v);
public FastRay2d(Ray2d ray) { Ray = ray; DirFlags = ray.Direction.DirFlags(); InvDir = 1.0 / ray.Direction; }
public static bool ApproximateEquals(this Ray2d a, Ray2d b) => ApproximateEquals(a, b, Constant <double> .PositiveTinyValue);
public static bool IsOrthogonalTo(this Ray2d r0, Ray2d r1) { return(r0.Direction.IsOrthogonalTo(r1.Direction)); }
public bool Equals(Ray2d other) => Origin.Equals(other.Origin) && Direction.Equals(other.Direction);
public double AngleBetween(Ray2d r) => Direction.AngleBetween(r.Direction);
public static bool IsParallelTo(this Ray2d r0, Ray2d r1) { return(r0.Direction.IsParallelTo(r1.Direction)); }
public static bool IsParallelTo(this Ray2d ray, V2d v) { return(ray.Direction.IsParallelTo(v)); }
public static bool IsParallelTo(this Ray2d r0, Ray2d r1) => r0.Direction.IsParallelTo(r1.Direction);
public static bool ApproximateEquals(this Ray2d a, Ray2d b, double tolerance) => ApproximateEquals(a.Origin, b.Origin, tolerance) && ApproximateEquals(a.Direction, b.Direction, tolerance);
public static bool IsParallelTo(this Ray2d r0, Ray2d r1, double epsilon = 1e-6) => r0.Direction.IsParallelTo(r1.Direction, epsilon);
public static bool IsOrthogonalTo(this Ray2d ray, V2d v) { return(ray.Direction.IsOrthogonalTo(v)); }