Candle v1.0
2D lighting for SFML

2D Line defined by an origin point and a direction vector. More...
#include <Line.hpp>
Public Member Functions  
Line (const sf::Vector2f &p1, const sf::Vector2f &p2)  
Construct a line that passes through p1 and p2 . More...  
Line (const sf::Vector2f &p, float angle)  
Construct a line defined by a point and an angle. More...  
sf::FloatRect  getGlobalBounds () const 
Get the global bounding rectangle of the line. More...  
int  relativePosition (const sf::Vector2f &point) const 
Return the relative position of a point to the line. More...  
float  distance (const sf::Vector2f &point) const 
Return the minimum distance of a point to the line. More...  
bool  intersection (const Line &lineB) const 
Returns a boolean if there is intersection of this line to another. More...  
bool  intersection (const Line &lineB, float &normA) const 
Returns the magnitude corresponding of the intersection of this line to another. More...  
bool  intersection (const Line &lineB, float &normA, float &normB) const 
Returns the magnitudes corresponding of the intersection of this line to another. More...  
sf::Vector2f  point (float param) const 
Get a point of the line. More...  
Public Attributes  
sf::Vector2f  m_origin 
Origin point of the line.  
sf::Vector2f  m_direction 
Direction vector (not necessarily normalized)  
2D Line defined by an origin point and a direction vector.
sfu::Line::Line  (  const sf::Vector2f &  p1, 
const sf::Vector2f &  p2  
) 
Construct a line that passes through p1
and p2
.
The direction is interpreted as p2  p1.
p1  First point 
p2  Second point 
sfu::Line::Line  (  const sf::Vector2f &  p, 
float  angle  
) 
Construct a line defined by a point and an angle.
The direction is interpreted as {cos(angle), sin(angle)}.
p  Origin point 
angle  Angle defining the line 
sf::FloatRect sfu::Line::getGlobalBounds  (  )  const 
Get the global bounding rectangle of the line.
The returned rectangle is in global coordinates, which means that it takes into account the transformations (translation, rotation, scale, ...) (see SFML).
int sfu::Line::relativePosition  (  const sf::Vector2f &  point  )  const 
Return the relative position of a point to the line.
If the point is to the right of the direction vector, the value returned is 1. If it is to the left, it is +1. If the point belongs to the line, returns 0.
point 
float sfu::Line::distance  (  const sf::Vector2f &  point  )  const 
Return the minimum distance of a point to the line.
point 
bool sfu::Line::intersection  (  const Line &  lineB  )  const 
Returns a boolean if there is intersection of this line to another.
lineB 
bool sfu::Line::intersection  (  const Line &  lineB, 
float &  normA  
)  const 
Returns the magnitude corresponding of the intersection of this line to another.
If there is an intersection, the output argument normA
contains the magnitude required to get the intersection point from this line direction.
lineB  
normA  (Output argument) 
bool sfu::Line::intersection  (  const Line &  lineB, 
float &  normA,  
float &  normB  
)  const 
Returns the magnitudes corresponding of the intersection of this line to another.
If there is an intersection, the output argument normB
contains the magnitude required to get the intersection point from lineB direction and normA
, the magnitude required to get the intersection point from this line direction.
lineB  
normA  (Output argument) 
normB  (Output argument) 
sf::Vector2f sfu::Line::point  (  float  param  )  const 
Get a point of the line.
The point is obtained is m_origin + param * m_direction
param 