src/hmisc/types/geometry_primitives

    Dark Mode
Search:
Group by:
  Source   Edit

Types

Line = object
  x1*, x2*, y1*, y2*: float
  Source   Edit
Line3 = object
  s*, e*: Vec3
  Source   Edit
Point[Num] = object
  x*: Num
  y*: Num
  Source   Edit
Radian = distinct float
  Source   Edit
Size3 = object
  w*, d*, h*: float
  Source   Edit
Vec = object
  x*, y*: float
  Source   Edit
Vec3 = object
  x*, y*, z*: float
  Source   Edit

Procs

func `$`(l: Line): string {....raises: [ValueError], tags: [].}
  Source   Edit
func `$`(v: Vec): string {....raises: [ValueError], tags: [].}
  Source   Edit
func `*`(a: Vec; s: float): Vec {....raises: [], tags: [].}
  Source   Edit
func `*`(s: float; a: Vec): Vec {....raises: [], tags: [].}
  Source   Edit
func `+`(a, b: Vec): Vec {....raises: [], tags: [].}
  Source   Edit
func `+`(a, b: Vec3): Vec3 {....raises: [], tags: [].}
  Source   Edit
func `-`(a, b: Vec): Vec {....raises: [], tags: [].}
  Source   Edit
func `/`(a: Vec3; denom: float): Vec3 {....raises: [], tags: [].}
  Source   Edit
func `/`(p: Vec; a: float): Vec {....raises: [], tags: [].}
  Source   Edit
func arg(l: Line): float {....raises: [], tags: [].}
  Source   Edit
func arg(p: Vec): float {....raises: [], tags: [].}
Return vector argument in polar coordinate system   Source   Edit
func begin(l: Line): Vec {....raises: [], tags: [].}
  Source   Edit
func cos(r: Radian): float {....raises: [], tags: [].}
  Source   Edit
func final(l: Line): Vec {....raises: [], tags: [].}
  Source   Edit
func flip(l: Line): Line {....raises: [], tags: [].}
  Source   Edit
func flip(v: Vec): Vec {....raises: [], tags: [].}
Return reversed vector   Source   Edit
func inRange(val: float; rng: (float, float)): bool {....raises: [], tags: [].}
  Source   Edit
func intersect(l1, l2: Line): Option[Vec] {....raises: [], tags: [].}
Calculate point of intersection between two lines if any. Intersection is only counted if intersection point is between begin and end points for both lines. Intersections 'at infinity' does not count.   Source   Edit
func intersect(l: (Line, Line)): Option[Vec] {....raises: [], tags: [].}
  Source   Edit
func invert(pos: RelPos): RelPos {....raises: [], tags: [].}
  Source   Edit
func isNanOrInf(f: float): bool {....raises: [], tags: [].}
  Source   Edit
func len(l: Line): float {....raises: [], tags: [].}
  Source   Edit
func magnitude(a: Vec3): float {....raises: [], tags: [].}
  Source   Edit
func magnitude(l: Line): float {....raises: [], tags: [].}
Return length of the line   Source   Edit
func magnitude(p: Vec): float {....raises: [], tags: [].}
Calculate magnitude of 2d vector   Source   Edit
func makeLine(a, b: Vec): Line {....raises: [], tags: [].}
Create two lines using a, b as start/end point   Source   Edit
func makeLine(p: (Vec, Vec)): Line {....raises: [], tags: [].}
Create two lines using (a, b) as start/end point   Source   Edit
func makePoint[Num](pos: (Num, Num)): auto
  Source   Edit
func makePoint[Num](x, y: Num): auto
  Source   Edit
proc makeSize3(w, d, h: int | float): Size3
  Source   Edit
proc makeVec(x, y: int | float): Vec
  Source   Edit
proc makeVec3(x: float = 0.0; y: float = 0.0; z: float = 0.0): Vec3 {.
    ...raises: [], tags: [].}
  Source   Edit
func makeVec3(x: int = 0; y: int = 0; z: int = 0): Vec3 {....raises: [], tags: [].}
  Source   Edit
func moveAlong(l: Line; v: Vec; distance: float): Line {....raises: [], tags: [].}
Move line in the direction of the vector by distance   Source   Edit
func norm(a: Vec3): Vec3 {....raises: [], tags: [].}
  Source   Edit
func norm(l: Line): Vec {....raises: [], tags: [].}
  Source   Edit
func norm(p: Vec): Vec {....raises: [], tags: [].}
Return normal vector   Source   Edit
func nperp(l: Line): Vec {....raises: [], tags: [].}
  Source   Edit
func onSegment(p: Vec; l: Line): bool {....raises: [], tags: [].}
  Source   Edit
func perp(v: Vec): Vec {....raises: [], tags: [].}
Return perpendicular vector   Source   Edit
func rotate(v: Vec; a: float): Vec {....raises: [], tags: [].}
CCW rotate vector by a radians   Source   Edit
func scalar(a, b: Vec): float {....raises: [], tags: [].}
  Source   Edit
func shiftNormal(l: Line; distance: float): Line {....raises: [], tags: [].}
Move line by distance in the direction perpendicular to it's vector direction   Source   Edit
func shiftX[Num](p: Point[Num]; dx: Num): Point[Num]
  Source   Edit
func shiftXY[Num](p: (Num, Num); dx: Num; dy: Num): (Num, Num)
  Source   Edit
func shiftXY[Num](p: Point[Num]; dx: Num; dy: Num): Point[Num]
  Source   Edit
func shiftY[Num](p: Point[Num]; dy: Num): Point[Num]
  Source   Edit
func sin(r: Radian): float {....raises: [], tags: [].}
  Source   Edit
func toVec(l: Line): Vec {....raises: [], tags: [].}
Return vector with magnitude and direction equal to line   Source   Edit
func toVec3(pos: Vec): Vec3 {....raises: [], tags: [].}
  Source   Edit
func unpack[Num](p: Point[Num]): (Num, Num)
  Source   Edit

Converters

converter toVec[N: float | int](pos: (N, N)): Vec
  Source   Edit