Ipelib: ipe::Segment Class Reference

Ipelib

Public Member Functions | Public Attributes | List of all members
ipe::Segment Class Reference
Ipe Geometry

`#include <ipegeo.h>`

## Public Member Functions
| Segment ()
| Segment (const Vector &p, const Vector &q)
Line | line () const
double | distance (const Vector &v, double bound) const
double | distance (const Vector &v) const
bool | project (const Vector &v, Vector &projection) const
bool | intersects (const Segment &seg, Vector &pt) const
bool | intersects (const Line &l, Vector &pt) const
bool | snap (const Vector &mouse, Vector &pos, double &bound) const

## Public Attributes
Vector | iP
Vector | iQ

## Detailed Description

A directed line segment.

## Constructor & Destructor Documentation

## ◆ Segment() [1/2]

ipe::Segment::Segment | ( |  | ) |
| inline

Create uninitialized segment.

## ◆ Segment() [2/2]

ipe::Segment::Segment | ( | const Vector & | p,
|  | const Vector & | q
| ) |  |
| inlineexplicit

## Member Function Documentation

## ◆ line()

Line ipe::Segment::line | ( |  | ) | const
| inline

Return directed line supporting the segment.

Referenced by ipe::Arc::intersect(), intersects(), and ipe::Snap::setEdge().

## ◆ distance() [1/2]

double Segment::distance | ( | const Vector & | v,
|  | double | bound
| ) |  | const

Returns distance between segment and point v, but may just return bound when its larger than bound.

Referenced by ipe::CurveSegment::distance().

## ◆ distance() [2/2]

double Segment::distance | ( | const Vector & | v | ) | const

Returns distance between segment and point v

References ipe::Vector::factorize().

## ◆ project()

bool Segment::project | ( | const Vector & | v,
|  | Vector & | projection
| ) |  | const

Project point v orthogonally on segment. Returns false if the point falls outside the segment.

References ipe::Vector::factorize().

Referenced by ipe::Bezier::snap().

## ◆ intersects() [1/2]

bool Segment::intersects | ( | const Segment & | seg,
|  | Vector & | pt
| ) |  | const

Compute intersection point. Return `false` if segs don't intersect.

References iP, iQ, and line().

Referenced by ipe::Bezier::intersect(), and ipe::Bezier::snap().

## ◆ intersects() [2/2]

bool Segment::intersects | ( | const Line & | l,
|  | Vector & | pt
| ) |  | const

Compute intersection point. Return `false` if no intersection.

## ◆ snap()

bool Segment::snap | ( | const Vector & | mouse,
|  | Vector & | pos,
|  | double & | bound
| ) |  | const

Snap mouse position to this segment.

If distance between mouse and the segment is less than bound, then set pos to the point on the segment, bound to the distance, and return true.

References ipe::Linear::Linear(), and ipe::Vector::snap().

Referenced by ipe::CurveSegment::snapBnd().

## Member Data Documentation

## ◆ iP

Vector ipe::Segment::iP

First endpoint.

Referenced by ipe::Bezier::intersect(), ipe::Arc::intersect(), intersects(), ipe::Snap::setEdge(), and ipe::Shape::Shape().

## ◆ iQ

Vector ipe::Segment::iQ

Second endpoint.

Referenced by ipe::Bezier::intersect(), ipe::Arc::intersect(), intersects(), ipe::Snap::setEdge(), and ipe::Shape::Shape().

The documentation for this class was generated from the following files:

- ipegeo.h
- ipegeo.cpp