class Gambit::ColliderBit::LineSegment

A simple container for a line segment on an xy plane. More…

#include <PointsAndLines.hpp>

Public Functions

Name
voidinit(double x1, double y1, double x2, double y2, double extendFrac =-1.)
Coordinate initializer / recycler.
voidinit(const P2 & p1, const P2 & p2, double extendFrac =-1.)
Point initializer / recycler.
LineSegment()
Default constructor.
LineSegment(double x1, double y1, double x2, double y2, double extendFrac =-1.)
Coordinate constructor.
LineSegment(const P2 & p1, const P2 & p2, double extendFrac =0.)
Point constructor.
LineSegment(const LineSegment & other)
Copy constructor.
LineSegment &operator=(const LineSegment & other)
Copy assignment operator.
const P2getp1() const
const P2getp2() const
doubleslope() const
Get the slope of the line segment.
doublem() const
Alias for slope.
doubleintercept() const
Get the y-intercept of the full line which contains this segment.
doubleb() const
Alias for intercept.
doubleabs() const
Get the length of the vector from the origin to this point.
doubler() const
Alias for abs.
P2intersectsAt(const LineSegment & other) const
Determine if this intersects with other and where.

Detailed Description

class Gambit::ColliderBit::LineSegment;

A simple container for a line segment on an xy plane.

This class depends on the P2 class above. It has a built in algorithm to detect intersection with another LineSegment.

Public Functions Documentation

function init

inline void init(
    double x1,
    double y1,
    double x2,
    double y2,
    double extendFrac =-1.
)

Coordinate initializer / recycler.

function init

inline void init(
    const P2 & p1,
    const P2 & p2,
    double extendFrac =-1.
)

Point initializer / recycler.

function LineSegment

inline LineSegment()

Default constructor.

function LineSegment

inline LineSegment(
    double x1,
    double y1,
    double x2,
    double y2,
    double extendFrac =-1.
)

Coordinate constructor.

function LineSegment

inline LineSegment(
    const P2 & p1,
    const P2 & p2,
    double extendFrac =0.
)

Point constructor.

function LineSegment

inline LineSegment(
    const LineSegment & other
)

Copy constructor.

function operator=

inline LineSegment & operator=(
    const LineSegment & other
)

Copy assignment operator.

function getp1

inline const P2 getp1() const

function getp2

inline const P2 getp2() const

function slope

inline double slope() const

Get the slope of the line segment.

function m

inline double m() const

Alias for slope.

function intercept

inline double intercept() const

Get the y-intercept of the full line which contains this segment.

function b

inline double b() const

Alias for intercept.

function abs

inline double abs() const

Get the length of the vector from the origin to this point.

function r

inline double r() const

Alias for abs.

function intersectsAt

inline P2 intersectsAt(
    const LineSegment & other
) const

Determine if this intersects with other and where.


Updated on 2024-07-18 at 13:53:31 +0000