InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PMLine Class Reference

#include <PMLine.h>

Public Member Functions

 PMLine ()
 
 PMLine (const PMReal &slope, const PMReal &yIntercept)
 
 PMLine (const PMReal &xIntercept)
 
 PMLine (const PMPoint &P1, const PMPoint &P2)
 
bool16 SolveForY (const PMReal &X, PMReal *Y) const
 
bool16 SolveForX (const PMReal &Y, PMReal *X) const
 
PMLine SolveForPerpendicularLine (const PMPoint &P) const
 
bool16 SolveForIntersectPoint (const PMLine &otherLine, PMPoint *intersectPt) const
 
bool16 SolveForIntersectPoint (const PMPoint &P1, const PMPoint &P2, PMPoint *intersectPt) const
 
bool16 GetSlope (PMReal *pSlope) const
 
bool16 FindPointOnLine (const PMPoint &P0, const PMReal &dist, const PMPoint &refPoint, PMPoint *retPt) const
 
bool16 ContainsPoint (const PMPoint &point) const
 

Friends

bool16 operator== (const PMLine &a, const PMLine &b)
 
bool16 operator!= (const PMLine &a, const PMLine &b)
 

Detailed Description

A C++ class for dealing with lines. A PMLine is specified by a slope, x and/or y intercept.

Constructor & Destructor Documentation

PMLine::PMLine ()

The default constructor makes no assumptions about what a default line is.

PMLine::PMLine (const PMRealslope,
const PMRealyIntercept 
)

Construct a line from the given slope and y intercept.

Parameters
slopespecifies the slope.
yInterceptis the y intercept.
PMLine::PMLine (const PMRealxIntercept)

Construct a line with x intercept. In this case, the line has an infinite slope, i.e. x = some constant.

Parameters
xInterceptis the x intercept.
PMLine::PMLine (const PMPointP1,
const PMPointP2 
)

Construct a line that passes between the two given points. If P1 == P2 the line is undefined.

Parameters
P1is the first point.
P2is the second point.

Member Function Documentation

bool16 PMLine::ContainsPoint (const PMPointpoint) const

Returns kTrue if the line contains the given point.

Parameters
pointis the point to check.
Returns
true if point is on the line.
bool16 PMLine::FindPointOnLine (const PMPointP0,
const PMRealdist,
const PMPointrefPoint,
PMPointretPt 
) const

Find the point on the line that is dist distance away from P0. Returns true if a solution exists. When there are two solutions (which is most of the time) it picks the one farthest away from refPoint.

Parameters
P0is the anchor point.
distspecifies the distance from P0.
refPointis the reference point.
retPtis the point on the line.
Returns
true if a solution exists.
bool16 PMLine::GetSlope (PMRealpSlope) const

Return the slope of the line.

Parameters
pSlopeis the slope of the line.
Returns
true if the slope is infinite, otherwise it returns kFalse
bool16 PMLine::SolveForIntersectPoint (const PMLineotherLine,
PMPointintersectPt 
) const

Returns whether or not the lines intersect, and if they do, fills in the intersect point. If the two lines are equal the following call will return kFalse even though the two lines intersect at every point.

Parameters
otherLineis the line to check for interception.
intersectPtis the resulting intersecting point.
Returns
true if lines intersect.
bool16 PMLine::SolveForIntersectPoint (const PMPointP1,
const PMPointP2,
PMPointintersectPt 
) const

Finds the intersecting point that lies between P1 and P2 if it exists Essentially the same as the above method but puts constraints on the answer.

Parameters
P1is the first point.
P1is the second point.
intersectPtis the resulting intersecting point.
Returns
true if line defined by P1 and P2 intersect this line between P1 and P2.
PMLine PMLine::SolveForPerpendicularLine (const PMPointP) const

Returns the line that is perpendicular to this line and passes through the given point.

Parameters
Pis the point the perpendicular line will pass through.
Returns
the perpendicular line.
bool16 PMLine::SolveForX (const PMRealY,
PMRealX 
) const

Returns true if the solution for X given Y exists. Fills in X.

Parameters
Yis the given y value.
Xis solution for the given y value.
Returns
true if solution for X exists.
bool16 PMLine::SolveForY (const PMRealX,
PMRealY 
) const

Returns true if the solution for Y given X exists. Fills in Y.

Parameters
Xis the given x value.
Yis solution for the given x value.
Returns
true if solution for y exists.

Friends And Related Function Documentation

bool16 operator!= (const PMLinea,
const PMLineb 
)
friend

Return true if two lines are not equal.

Parameters
ais line a.
bis line b.
Returns
true if line a and b are not equal.
bool16 operator== (const PMLinea,
const PMLineb 
)
friend

Return true if two lines are equal.

Parameters
ais line a.
bis line b.
Returns
true if line a and b are equal.