public PointLiesOnSegment ( Vector2 point ) : bool | ||
point | Vector2 | |
Résultat | bool |
public override SegmentCollisionResult CollideLineSegment(ShapeLineSegment other) { //We can just do a line-line intersection, as if both Segments are Lines, //and then see if the point of intersection //is on both segments. No need for ridiculous math here! ShapeLine one = ToLine(); ShapeLine two = other.ToLine(); LineCollisionResult res = one.CollideLines(two); if(res.Collides && PointLiesOnSegment(res.PointOfIntersection) && other.PointLiesOnSegment(res.PointOfIntersection)) { return new SegmentCollisionResult {Collides = true, PointOfCollision = res.PointOfIntersection}; } return new SegmentCollisionResult(); }