All Projects → d3 → versor

d3 / versor

Licence: other
a home for Mike Bostock's versor.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to versor

rotation master
Provide conversion between the major representations of 3D rotation and visualize the orientation of a rigid body
Stars: ✭ 157 (+503.85%)
Mutual labels:  quaternion, rotation
jpn-atlas
TopoJSONフォーマットの日本の国、都道府県、市区町村の境界データ。Japanese municipality and prefecture boundary data in topojson format.
Stars: ✭ 17 (-34.62%)
Mutual labels:  d3, d3-geo
Quadcopter SimCon
Quadcopter Simulation and Control. Dynamics generated with PyDy.
Stars: ✭ 84 (+223.08%)
Mutual labels:  quaternion, rotation
Quaternion.js
A JavaScript Quaternion library
Stars: ✭ 86 (+230.77%)
Mutual labels:  quaternion, rotation
aws-mlu-explain
Visual, Interactive Articles About Machine Learning: https://mlu-explain.github.io/
Stars: ✭ 46 (+76.92%)
Mutual labels:  d3
d3-force-webgl-integration-demo
Integrating WebGL and D3-force to improve performance. 👻
Stars: ✭ 44 (+69.23%)
Mutual labels:  d3
react-search-example
📉📈 An example of using React with D3, Lunr.js and an autocomplete UI to build an accessible keyboard-centric search experience. Also – service workers for offline caching, and desktop app with Electron.
Stars: ✭ 15 (-42.31%)
Mutual labels:  d3
quaternion-conventions
An overview of different quaternion implementations and their chosen order: x-y-z-w or w-x-y-z?
Stars: ✭ 24 (-7.69%)
Mutual labels:  quaternion
QuickImageFX
Simplifying image manipulation using GDI, Graphics32, OpenCV or Vampyre Imaging libraries
Stars: ✭ 41 (+57.69%)
Mutual labels:  rotation
a2d3
Flexible and extensible D3 directives for Angular 2
Stars: ✭ 22 (-15.38%)
Mutual labels:  d3
silky-charts
A silky smooth D3/React library
Stars: ✭ 38 (+46.15%)
Mutual labels:  d3
kubed
No description or website provided.
Stars: ✭ 68 (+161.54%)
Mutual labels:  d3
tree-chart
Flexible tree chart using Canvas and Svg, powered by D3.js; ✅Support Vue, Vue3 and React;
Stars: ✭ 265 (+919.23%)
Mutual labels:  d3
vue-network-d3
D3 Force-Directed Graph as Vue Component. D3 力导向图作为 Vue 组件。
Stars: ✭ 35 (+34.62%)
Mutual labels:  d3
proteic
Streaming and static data visualization for the modern web.
Stars: ✭ 37 (+42.31%)
Mutual labels:  d3
hlml
vectorized high-level math library
Stars: ✭ 42 (+61.54%)
Mutual labels:  quaternion
d3-ng2-demo
Reusable visual power? A demo of using D3 version 4 with Angular 2+.
Stars: ✭ 53 (+103.85%)
Mutual labels:  d3
dienstplan
Slack bot app for duty rotations
Stars: ✭ 14 (-46.15%)
Mutual labels:  rotation
topola
Topola – online genealogy visualization
Stars: ✭ 57 (+119.23%)
Mutual labels:  d3
course-17-18
🎓 Frontend 3 · 2017-2018 · Curriculum and Syllabus 📊
Stars: ✭ 39 (+50%)
Mutual labels:  d3

Versor

Rotate the globe with the mouse.

The naïve method uses mouse.x and mouse.y as proxies for longitude and latitude. It works when the rotation is small, but try to put the globe "upside-down" and suddenly moving the mouse to the left rotates the globe to the right, and vice versa.

The correct solution is to track the spherical coordinates of the point that is under the mouse, and apply a rotation to the globe that will move the initial point to the current mouse position. Computing that rotation involves quaternions.

This method, introduced by Jason Davies and Mike Bostock, is called versor dragging.

This module contains the quaternion & versor functions. For a directly usable package, see d3-inertia.

In Node:

const versor = require("versor");

// interpolate angles (slerp), see https://observablehq.com/@d3/world-tour
versor.interpolate(rotation0, rotation1); // function of (t)

// quaternion to rotate between p0 and p1, see d3-inertia
const p0 = [0, 0],
    p1 = [90, 0],
    c0 = versor.cartesian(p0),
    c1 = versor.cartesian(p1);
versor.delta(c0, c1); // [0.7071, 0.7071, 0, 0]

// tweening: quaternion to rotate halfway between p0 and p1
versor.delta(c0, c1, 0.5); // [0.9239, 0.3827, 0, 0]


// utilities

// get cartesian coordinates [x, y, z] given spherical coordinates [λ, φ].
versor.cartesian = function(e) {
  var l = e[0] * radians, p = e[1] * radians, cp = cos(p);
  return [cp * cos(l), cp * sin(l), sin(p)];
};

// create a quaternion from Euler angles
const q0 = versor([90,0,0]); // [0.7071068, 0.7071068, 0, 0]
const q1 = versor([0,90,0]); // [0.7071068, 0, 0.7071068, 0]

// the quaternion that represents q0 * q1.
q01 = versor.multiply(q0, q1); // [0.5, 0.5, 0.5, 0.5]

// Euler rotation angles [λ, φ, γ] for the given quaternion.
versor.rotation(q01); // [90, 0, 90]

If you use npm, npm install versor. You can also download the latest release on GitHub. For vanilla HTML in modern browsers, import versor from Skypack:

<script type="module">
  import versor from "https://cdn.skypack.dev/[email protected]";
  const t = versor([90,0,0]);
</script>

For legacy environments, you can load versor’s UMD bundle from an npm-based CDN such as jsDelivr; a versor global is exported:

<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script>
  
versor([90,0,0]);

</script>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].