r-geometric

2.0.1 • Public • Published

r-geometric

Installation

npm install r-geometric

Use

import RGeometricObject from 'r-geometric';

const RGeometric = new RGeometricObject();

getLength()

get line object as parameter and returns number as length of line.
let length = RGeometric.getLength({x1:10,y1:10,x2:20,y2:-40});
//returns 50.99019513592785

[alt text]

getAngle()

get line object as parameter and returns number as angle of line.
let angle = RGeometric.getAngle({x1:10,y1:10,x2:20,y2:-40});
//returns 281.309932

[alt text]

getMeet()

get 2 lines object as parameters and returns number as meet point(array of 2 number) of lines.
let meet = RGeometric.getMeet({x1:10,y1:10,x2:20,y2:-40},{x1:100,y1:-10,x2:40,y2:50});
//returns [-7.5, 97.5]

[alt text]

getPrepToLine()

get a line object and a point array as parameters and returns a point array as prependicular from point to line.
let prep = RGeometric.getPrepToLine({x1:10,y1:10,x2:20,y2:-40},[-60,-40]);
//returns [x, y]

[alt text]

getXOnLineByY()

get a line object and x value as parameters and returns a number as y .
let x = RGeometric.getXOnLineByY({x1:10,y1:10,x2:20,y2:-40},20);
//returns x

[alt text]

getYOnLineByX()

get a line object and y value as parameters and returns a number as x .
let y = RGeometric.getYOnLineByX({x1:10,y1:10,x2:20,y2:-40},20);
//returns y

[alt text]

getLineBySLA()

get a point array and length value and angle as parameters and returns a line object .
in this example this function returns a line object by start from 0,0 and length equal 20 and angle equal 45.
let y = RGeometric.getYOnLineByX([0,0],20,45);
//returns {x1:...,y1:...,x2:...,y2:...}

[alt text]

getPointsByDivide()

get a line object and divide value as parameters and returns midpoints array .
in this example , This function divides the line into 6 equal parts by return 5 mid points.
let midPoints = RGeometric.getPointsByDivide({x1:0,y1:0,x2:100,y2:60},6);
//returns [[x,y],[x,y],[x,y],[x,y],[x,y]]

[alt text]

getParallelPoints()

get array of points and offset value (number) as parameters and returns parallel points array .
let parallelPoints = RGeometric.getParallelPoints([[x1,y1],[x2,y2],[x3,y3],[x4,y4],[x5,y5]],30);
//returns [[a1,b1],[a2,b2],[a3,b3],[a4,b4],[a5,b5]]

[alt text]

Readme

Keywords

none

Package Sidebar

Install

npm i r-geometric

Weekly Downloads

1

Version

2.0.1

License

ISC

Unpacked Size

14.9 kB

Total Files

3

Last publish

Collaborators

  • mohamadfeiz