A 2D segment. More...
#include <seg2.h>
Public Member Functions | |
seg2 (const vec2< type > &a, const vec2< type > &b) | |
Creates a new segment with the given extremities. | |
type | lineDistSq (const vec2< type > &p) const |
Returns the square distance between the given point and the line defined by this segment. | |
type | segmentDistSq (const vec2< type > &p) const |
Returns the square distance between the given point and this segment. | |
bool | intersects (const seg2 &s) const |
Returns true if this segment intersects the given segment. | |
bool | intersects (const seg2 &s, vec2< type > *i) const |
Returns true if this segment intersects the given segment. | |
bool | intersects (const box2< type > &r) const |
Returns true if this segment is inside or intersects the given bounding box. | |
bool | contains (const vec2< type > &p, type w) const |
Returns true if this segment, with the given width, contains the given point. | |
Public Attributes | |
vec2< type > | a |
One of the segment extremity. | |
vec2< type > | ab |
The vector joining a to the other segment extremity. |
A 2D segment.
proland::seg2< type >::seg2 | ( | const vec2< type > & | a, | |
const vec2< type > & | b | |||
) | [inline] |
Creates a new segment with the given extremities.
a | a segment extremity. | |
b | the other segment extremity. |
bool proland::seg2< type >::contains | ( | const vec2< type > & | p, | |
type | w | |||
) | const [inline] |
Returns true if this segment, with the given width, contains the given point.
More precisely this method returns true if the stroked path defined from this segment, with a cap "butt" style, contains the given point.
p | a point. | |
w | width of this segment. |
bool proland::seg2< type >::intersects | ( | const box2< type > & | r | ) | const [inline] |
Returns true if this segment is inside or intersects the given bounding box.
r | a bounding box. |
bool proland::seg2< type >::intersects | ( | const seg2< type > & | s, | |
vec2< type > * | i | |||
) | const [inline] |
Returns true if this segment intersects the given segment.
If there is an intersection it is returned in the vector.
s | a segment. | |
i | where to store the intersection point, if any. |
bool proland::seg2< type >::intersects | ( | const seg2< type > & | s | ) | const [inline] |
Returns true if this segment intersects the given segment.
s | a segment. |
type proland::seg2< type >::lineDistSq | ( | const vec2< type > & | p | ) | const [inline] |
Returns the square distance between the given point and the line defined by this segment.
p | a point. |
type proland::seg2< type >::segmentDistSq | ( | const vec2< type > & | p | ) | const [inline] |
Returns the square distance between the given point and this segment.
p | a point. |
vec2<type> proland::seg2< type >::a |
One of the segment extremity.
vec2<type> proland::seg2< type >::ab |
The vector joining a to the other segment extremity.