Home Reference Source

Function

Static Public Summary
public

ccw(P0: Point, P1: Point, P2: Point): Object

ccw allows to know if traveling from P0 to P1 to P2 we turn counterclockwise assuming we are in cartesian space where X is directed to right and Y axis goes up and assuming the 3 points are distinct points if any points are identical ccw wil trow an error from p.

public

fixDec(n: *)

public

getDegrees(angle: *, angleSystem: *)

public

getGradians(angle: *, angleSystem: *)

public

getRadians(angle: *, angleSystem: *)

public

isNumeric(n: *)

public

roundNumber(num: number | string, precision: number): number

Rounds number to a given decimal precision

Static Public

public ccw(P0: Point, P1: Point, P2: Point): Object source

import {ccw} from 'cgil-geom2d/src/ccw.js'

ccw allows to know if traveling from P0 to P1 to P2 we turn counterclockwise assuming we are in cartesian space where X is directed to right and Y axis goes up and assuming the 3 points are distinct points if any points are identical ccw wil trow an error from p. 350 of Book : Algorithms in C++ by Robert Sedgewick Addison-Wesley ISBN 0-201-51059-6 here are some examples : Point.ccw(P(0,0), P(2,0), P(2,3)) // should return this Object : {'counterClockwise': true, 'allPointsAreColinear': false, 'value': 1}

Point.ccw(PP(0,0), P(2,0), P(2,-3)) // should return this Object : {'counterClockwise': false, 'allPointsAreColinear': false, 'value': -1}

let {counterClockwise, allPointsAreColinear, value} = Point.ccw(Point(0, 0.3), Point(1, 0.6), Point(2, 0.9)) will give you 'counterClockwise': true, 'allPointsAreColinear': true, 'value': 1 have a look on my unit test in Point.spec.js for more examples

Params:

NameTypeAttributeDescription
P0 Point
P1 Point
P2 Point

Return:

Object

1 when turn is counterclockwise, -1 if not, and 0 when P2 colinear in segment between P0 and P1

public fixDec(n: *) source

import {fixDec} from 'cgil-geom2d/src/utils.js'

Params:

NameTypeAttributeDescription
n *

public getDegrees(angle: *, angleSystem: *) source

import {getDegrees} from 'cgil-geom2d/src/utils.js'

Params:

NameTypeAttributeDescription
angle *
angleSystem *
  • optional

public getGradians(angle: *, angleSystem: *) source

import {getGradians} from 'cgil-geom2d/src/utils.js'

Params:

NameTypeAttributeDescription
angle *
angleSystem *
  • optional

public getRadians(angle: *, angleSystem: *) source

import {getRadians} from 'cgil-geom2d/src/utils.js'

Params:

NameTypeAttributeDescription
angle *
angleSystem *
  • optional

public isNumeric(n: *) source

import {isNumeric} from 'cgil-geom2d/src/utils.js'

Params:

NameTypeAttributeDescription
n *

public roundNumber(num: number | string, precision: number): number source

import {roundNumber} from 'cgil-geom2d/src/utils.js'

Rounds number to a given decimal precision

Params:

NameTypeAttributeDescription
num number | string
precision number

display precision

Return:

number