Example #1
0
        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)));
        }
Example #2
0
 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);
 }
Example #3
0
 public static bool IsCrossing(StraightLine self, HalfStraightLine other)
 {
     return(Vector2Util.Cross(self.dir, other.p - self.p) * Vector2Util.Cross(self.dir, other.dir) < 0f);
 }
Example #4
0
 public static bool IsCrossing(StraightLine self, StraightLine other)
 {
     // a × b == 0 ⇔ a // b
     return(!(Mathf.Abs(Vector2Util.Cross(self.dir, other.dir)) < EPS));
 }
Example #5
0
        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);
        }
Example #6
0
 public static Vector2 GetIntersection(StraightLine self, LineSegment other)
 {
     return(GetIntersectionWithLineSegment(other, self.p, self.dir));
 }