Skip to content

jitx/shapes/Segment

Package name: jitx/shapes/Segment

Summary

Segment

Line Segment

Constructors

Function Description
Segment Constructor for defstruct Segment

Functions

Function Description
center Find the midpoint of the segment.
angle-degrees Calculate the angle of the vector.
length Calculate the length of the segment.

Definitions

Segment

Line Segment

public defstruct Segment <: Shape & HasMetaUtils :
    source: Point
    target: Point

  • source: Point - Start point of this line segment.

  • target: Point - End point of this line segment.

A line segment specified by its start and end point.

Constructors

Segment

Constructor for defstruct Segment

public defn Segment (source:Point, target:Point)

Functions

center

Find the midpoint of the segment.

public defn center (seg:Segment) -> Point

  • seg: Segment - The segment to find the midpoint of.
  • Returns Point

In other words, the average of the start and end points of the segment.

angle-degrees

Calculate the angle of the vector.

public defn angle-degrees (seg:Segment) -> Double

  • seg: Segment - The segment to find the angle of.
  • Returns Double

The angle is in degrees counter-clockwise from the positive X axis of the line from the source to the target of the segment.

length

Calculate the length of the segment.

public defn length (seg:Segment) -> Double

  • seg: Segment - The segment to calculate the length of.
  • Returns Double

Related Packages

Forwarded by packages: jitx/shapes, jitx