コード例 #1
0
 public static bool IsCrossing(HalfStraightLine self, HalfStraightLine other)
 {
     return(
         Vector2Util.Cross(self.dir, other.p - self.p) * Vector2Util.Cross(self.dir, other.dir) < 0f &&
         GetIntersectionParametric(self.p, self.dir, other.p, other.dir) >= 0f
         );
 }
コード例 #2
0
        public static bool IsCrossing(HalfStraightLine self, LineSegment other)
        {
            var v1 = other.p0 - self.p;
            var v2 = other.p1 - self.p;

            return(
                (Vector2.Dot(self.dir, v1) >= 0f || Vector2.Dot(self.dir, v2) >= 0f) &&
                Vector2Util.Cross(self.dir, v1) * Vector2Util.Cross(self.dir, v2) < 0f &&
                (GetIntersectionParametric(self.p, self.dir, other.p0, other.dir) >= 0f)
                );
        }
コード例 #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);
 }
コード例 #4
0
 public static Vector2 GetIntersection(HalfStraightLine self, LineSegment other)
 {
     return(GetIntersectionWithLineSegment(other, self.p, self.dir));
 }
コード例 #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);
        }
コード例 #6
0
 public static float GetDistance(HalfStraightLine self, Vector2 p)
 {
     return(Vector2.Dot(self.dir, p - self.p) < EPS?
            Vector2.Distance(self.p, p) :
                Mathf.Abs(Vector2Util.Cross(self.dir, p - self.p)) / self.dir.magnitude);
 }