Function ccpLineIntersect

#include <Geode/cocos/support/CCPointExtension.h>boolccpLineIntersect(,,,,,)

Since v0.99.1

A general line-line intersection test

Parameters

p1

is the startpoint for the first line P1 = (p1 - p2)

p2

is the endpoint for the first line P1 = (p1 - p2)

p3

is the startpoint for the second line P2 = (p3 - p4)

p4

is the endpoint for the second line P2 = (p3 - p4)

s

is the range for a hitpoint in P1 (pa = p1 + s*(p2 - p1))

t

is the range for a hitpoint in P3 (pa = p2 + t*(p4 - p3))
Return value
bool indicating successful intersection of a line note that to truly test intersection for segments we have to make sure that s & t lie within [0..1] and for rays, make sure s & t > 0 the hit point is p3 + t * (p4 - p3); the hit point also is p1 + s * (p2 - p1);
Examples0