public static float GetDistance(StraightLine self, Vector2 p) { var v = p - self.p; // 本当は this.Cross(this.dir, v) / this.dir.magnitude だが、DirectionのMagnitudeは1. return(Mathf.Abs(Vector2Util.Cross(self.dir, v))); }
public static bool IsCrossing(StraightLine self, LineSegment other) { return(Vector2Util.Cross(self.dir, other.p0 - self.p) * Vector2Util.Cross(self.dir, other.p1 - self.p) < 0f); }
public static bool IsCrossing(StraightLine self, HalfStraightLine other) { return(Vector2Util.Cross(self.dir, other.p - self.p) * Vector2Util.Cross(self.dir, other.dir) < 0f); }
public static bool IsCrossing(StraightLine self, StraightLine other) { // a × b == 0 ⇔ a // b return(!(Mathf.Abs(Vector2Util.Cross(self.dir, other.dir)) < EPS)); }
public static Vector2 GetIntersection(StraightLine self, HalfStraightLine other) { var t = GetIntersectionParametric(self.p, self.dir, other.p, other.dir); return(self.p + t * self.dir); }
public static Vector2 GetIntersection(StraightLine self, LineSegment other) { return(GetIntersectionWithLineSegment(other, self.p, self.dir)); }