Line

Class Line

An infinite straight line that goes through two points.

Implements GeoShape

constructor (p1: Point, p2: Point): Line

Name Type Default Description
p1 Point    
p2 Point    

Property .flag

readonly Property .p1 : Point

readonly Property .p2 : Point

readonly Property .type : string

Default value: 'line'

Accessor .angle : number

The angle formed between this line and the x-axis.

Accessor .intercept : number

The y-axis intercept of this line.

Accessor .length : number

Accessor .lengthSquared : number

Accessor .line : Line

Accessor .midpoint : Point

The midpoint of this line.

Accessor .perpendicularBisector : Line

The perpendicular bisector of this line.

Accessor .perpendicularVector : Point

The point representing the perpendicular vector of this line.

Accessor .ray : Ray

Accessor .segment : Segment

Accessor .slope : number

The slope of this line.

Accessor .unitVector : Point

The point representing a unit vector along this line.

Method .at (t: number): Point

Gets the point at a specific offset along the line (opposite of .offset()).

Name Type Default Description
t number    

Method .contains (p: SimplePoint, tolerance: number): boolean

Checks if a point p lies on this line.

Name Type Default Description
p SimplePoint    
tolerance number    

Method .distanceSquared (p: Point): number

Squared distance between a point and a line.

Name Type Default Description
p Point    

Method .equals (other: Line, tolerance: number): boolean

Name Type Default Description
other Line    
tolerance number    

Method .offset (p: SimplePoint): number

Signed distance along the line (opposite of .at()).

Name Type Default Description
p SimplePoint    

Method .parallel (p: Point): Line

Finds the line parallel to this one, going through point p.

Name Type Default Description
p Point    

Method .perpendicular (p: Point): Line

Finds the line perpendicular to this one, going through point p.

Name Type Default Description
p Point    

Method .project (p: SimplePoint): Point

Projects a point p onto this line.

Name Type Default Description
p SimplePoint    

Method .reflect (l: Line): Line

Name Type Default Description
l Line    

Method .rotate (a: number, c: Point): Line

Rotates this line by a given angle (in radians), optionally around point c.

Name Type Default Description
a number    
c Point  

Method .scale (sx: number, sy: number): any

Name Type Default Description
sx number    
sy number  

Method .shift (x: number, y: number): any

Name Type Default Description
x number    
y number  

Method .side (p: SimplePoint, tolerance: number): number

Returns which side of this line a point p is on (or 0 on the line).

Name Type Default Description
p SimplePoint    
tolerance number    

Method .toString (): string

Method .transform (m: TransformMatrix): Line

Name Type Default Description
m TransformMatrix    

Method .translate (p: SimplePoint): any

Name Type Default Description
p SimplePoint    

Class Ray

An infinite ray defined by an endpoint and another point on the ray.

Extends Line

readonly Property .type

Default value: 'ray'

Method .contains (p: Point, tolerance: number): boolean

Name Type Default Description
p Point    
tolerance number    

Method .equals (other: Ray, tolerance: number): boolean

Name Type Default Description
other Ray    
tolerance number    

Method .toString (): string

Class Segment

A finite line segment defined by its two endpoints.

Extends Line

readonly Property .type

Default value: 'segment'

Method .contains (p: Point, tolerance: number): boolean

Name Type Default Description
p Point    
tolerance number    

Method .contract (x: number): Segment

Contracts (or expands) a line by a specific ratio.

Name Type Default Description
x number    

Method .equals (other: Segment, tolerance: number, oriented: boolean): boolean

Name Type Default Description
other Segment    
tolerance number    
oriented boolean false  

Method .project (p: SimplePoint): Point

Name Type Default Description
p SimplePoint    

Method .toString (): string


Copyright © 2024 Mathigon.org