GithubHelp home page GithubHelp logo

cdaringe / coordinate-systems Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 0.0 547 KB

Geometry coordinate converter for common 2d/3d coordinate systems

TypeScript 100.00%
coordinates cartesian polar spherical typescript

coordinate-systems's Introduction

coordinate-systems

convert between common 2d and 3d coordinate systems:

  1. cartesian (2d)
  2. cartesian (3d)
  3. polar (2d)
  4. cylindrical (3d)
  5. spherical (3d)

install

npm install --save coordinate-systems

usage

construct a Coordinate using one of the provided static constructor functions. Run the conversion member function to convert to an array of values in [x, y, z?]/[r, t, p?/z?] format.

import { Coordinate, CoordinateType } from 'coordinate-systems'

// static, short-hand contructors
// @note, radians assumed by default for polar-esque systems
const xy = Coordinate.cartesian([0, 5])
const xyz = Coordinate.cartesian([1, 2, 3])
Coordinate.polar([2, Math.PI / 4])
Coordinate.cartesian([0.5, 0.5, 0.707])
Coordinate.cylindrical([2, Math.PI / 4, 5])
Coordinate.spherical([5, (60 * Math.PI) / 180, (30 * Math.PI) / 180])

// classic constructor
new Coordinate({ coordinates: [3, 4, 5], isDegree: true, type: CoordinateType.CARTESIAN_3D })
new Coordinate({ coordinates: [3, 60, 4], isDegree: true, type: CoordinateType.CYLINDRICAL })
new Coordinate({ coordinates: [5, 60, 30], type: CoordinateType.SPHERICAL })

xy.polar() // [ 5, 1.5707963267948966 ] (i.e. radius 5, theta ฯ€/2 radians)
xyz.spherical() // [ 3.74..., 1.10..., 0.64... ] (radius, theta, phi)

because this is a typescript package, the interfaces are fully documented and can be seen in src/index.d.ts. this is usually not a tracked file, but tracked here strictly for documentation purposes.

coordinate-systems's People

Contributors

cdaringe avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

coordinate-systems's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency typescript to v3.9.10
  • chore(deps): update typescript-eslint monorepo to v2.34.0 (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)
  • chore(deps): update dependency @types/node to v20
  • chore(deps): update dependency ava to v6
  • chore(deps): update dependency husky to v9
  • chore(deps): update dependency lint-staged to v15
  • chore(deps): update dependency ts-node to v10
  • chore(deps): update dependency typescript to v5
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/workflow.yml
npm
package.json
  • lodash ^4
  • @types/lodash ^4.14.138
  • @types/node ^12.7.5
  • @typescript-eslint/eslint-plugin ^2.3.0
  • @typescript-eslint/parser ^2.3.0
  • ava ^2.4.0
  • husky ^3.0.5
  • lint-staged ^9.2.5
  • prettier-standard ^14.0.5
  • standardx ^5.0.0
  • ts-node ^8.4.1
  • typescript ^3.6.3

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.