Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

versor

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

versor - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

COPYING

138

build/versor.js

@@ -1,82 +0,82 @@

// https://github.com/Fil/versor Version 0.0.3. Copyright 2017 Mike Bostock.
// https://github.com/Fil/versor Version 0.0.4. Copyright 2018 Mike Bostock.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.versor = factory());
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.versor = factory());
}(this, (function () { 'use strict';
var acos = Math.acos;
var asin = Math.asin;
var atan2 = Math.atan2;
var cos = Math.cos;
var max = Math.max;
var min = Math.min;
var PI = Math.PI;
var sin = Math.sin;
var sqrt = Math.sqrt;
var radians = PI / 180;
var degrees = 180 / PI;
var acos = Math.acos,
asin = Math.asin,
atan2 = Math.atan2,
cos = Math.cos,
max = Math.max,
min = Math.min,
PI = Math.PI,
sin = Math.sin,
sqrt = Math.sqrt,
radians = PI / 180,
degrees = 180 / PI;
// Returns the unit quaternion for the given Euler rotation angles [λ, φ, γ].
var versor = function(e) {
var l = e[0] / 2 * radians, sl = sin(l), cl = cos(l), // λ / 2
p = e[1] / 2 * radians, sp = sin(p), cp = cos(p), // φ / 2
g = e[2] / 2 * radians, sg = sin(g), cg = cos(g); // γ / 2
return [
cl * cp * cg + sl * sp * sg,
sl * cp * cg - cl * sp * sg,
cl * sp * cg + sl * cp * sg,
cl * cp * sg - sl * sp * cg
];
};
// Returns the unit quaternion for the given Euler rotation angles [λ, φ, γ].
var versor = function(e) {
var l = e[0] / 2 * radians, sl = sin(l), cl = cos(l), // λ / 2
p = e[1] / 2 * radians, sp = sin(p), cp = cos(p), // φ / 2
g = e[2] / 2 * radians, sg = sin(g), cg = cos(g); // γ / 2
return [
cl * cp * cg + sl * sp * sg,
sl * cp * cg - cl * sp * sg,
cl * sp * cg + sl * cp * sg,
cl * cp * sg - sl * sp * cg
];
};
// Returns 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)];
};
// Returns 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)];
};
// Returns the Euler rotation angles [λ, φ, γ] for the given quaternion.
versor.rotation = function(q) {
return [
atan2(2 * (q[0] * q[1] + q[2] * q[3]), 1 - 2 * (q[1] * q[1] + q[2] * q[2])) * degrees,
asin(max(-1, min(1, 2 * (q[0] * q[2] - q[3] * q[1])))) * degrees,
atan2(2 * (q[0] * q[3] + q[1] * q[2]), 1 - 2 * (q[2] * q[2] + q[3] * q[3])) * degrees
];
};
// Returns the Euler rotation angles [λ, φ, γ] for the given quaternion.
versor.rotation = function(q) {
return [
atan2(2 * (q[0] * q[1] + q[2] * q[3]), 1 - 2 * (q[1] * q[1] + q[2] * q[2])) * degrees,
asin(max(-1, min(1, 2 * (q[0] * q[2] - q[3] * q[1])))) * degrees,
atan2(2 * (q[0] * q[3] + q[1] * q[2]), 1 - 2 * (q[2] * q[2] + q[3] * q[3])) * degrees
];
};
// Returns the quaternion to rotate between two cartesian points on the sphere.
// alpha for tweening [0,1]
versor.delta = function(v0, v1, alpha) {
if (arguments.length == 2) alpha = 1;
var w = cross(v0, v1), l = sqrt(dot(w, w));
if (!l) return [1, 0, 0, 0];
var t = alpha * acos(max(-1, min(1, dot(v0, v1)))) / 2, s = sin(t); // t = θ / 2
return [cos(t), w[2] / l * s, -w[1] / l * s, w[0] / l * s];
};
// Returns the quaternion to rotate between two cartesian points on the sphere.
// alpha for tweening [0,1]
versor.delta = function(v0, v1, alpha) {
if (arguments.length == 2) alpha = 1;
var w = cross(v0, v1), l = sqrt(dot(w, w));
if (!l) return [1, 0, 0, 0];
var t = alpha * acos(max(-1, min(1, dot(v0, v1)))) / 2, s = sin(t); // t = θ / 2
return [cos(t), w[2] / l * s, -w[1] / l * s, w[0] / l * s];
};
// Returns the quaternion that represents q0 * q1.
versor.multiply = function(q0, q1) {
return [
q0[0] * q1[0] - q0[1] * q1[1] - q0[2] * q1[2] - q0[3] * q1[3],
q0[0] * q1[1] + q0[1] * q1[0] + q0[2] * q1[3] - q0[3] * q1[2],
q0[0] * q1[2] - q0[1] * q1[3] + q0[2] * q1[0] + q0[3] * q1[1],
q0[0] * q1[3] + q0[1] * q1[2] - q0[2] * q1[1] + q0[3] * q1[0]
];
};
// Returns the quaternion that represents q0 * q1.
versor.multiply = function(q0, q1) {
return [
q0[0] * q1[0] - q0[1] * q1[1] - q0[2] * q1[2] - q0[3] * q1[3],
q0[0] * q1[1] + q0[1] * q1[0] + q0[2] * q1[3] - q0[3] * q1[2],
q0[0] * q1[2] - q0[1] * q1[3] + q0[2] * q1[0] + q0[3] * q1[1],
q0[0] * q1[3] + q0[1] * q1[2] - q0[2] * q1[1] + q0[3] * q1[0]
];
};
function cross(v0, v1) {
return [
v0[1] * v1[2] - v0[2] * v1[1],
v0[2] * v1[0] - v0[0] * v1[2],
v0[0] * v1[1] - v0[1] * v1[0]
];
}
function cross(v0, v1) {
return [
v0[1] * v1[2] - v0[2] * v1[1],
v0[2] * v1[0] - v0[0] * v1[2],
v0[0] * v1[1] - v0[1] * v1[0]
];
}
function dot(v0, v1) {
return v0[0] * v1[0] + v0[1] * v1[1] + v0[2] * v1[2];
}
function dot(v0, v1) {
return v0[0] * v1[0] + v0[1] * v1[1] + v0[2] * v1[2];
}
return versor;
return versor;
})));

@@ -1,1 +0,1 @@

(function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.versor=n()})(this,function(){"use strict";function t(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}var n=Math.acos,r=Math.asin,e=Math.atan2,a=Math.cos,u=Math.max,i=Math.min,o=Math.PI,f=Math.sin,c=Math.sqrt,s=o/180,h=180/o,d=function(t){var n=t[0]/2*s,r=f(n),e=a(n),u=t[1]/2*s,i=f(u),o=a(u),c=t[2]/2*s,h=f(c),d=a(c);return[e*o*d+r*i*h,r*o*d-e*i*h,e*i*d+r*o*h,e*o*h-r*i*d]};return d.cartesian=function(t){var n=t[0]*s,r=t[1]*s,e=a(r);return[e*a(n),e*f(n),f(r)]},d.rotation=function(t){return[e(2*(t[0]*t[1]+t[2]*t[3]),1-2*(t[1]*t[1]+t[2]*t[2]))*h,r(u(-1,i(1,2*(t[0]*t[2]-t[3]*t[1]))))*h,e(2*(t[0]*t[3]+t[1]*t[2]),1-2*(t[2]*t[2]+t[3]*t[3]))*h]},d.delta=function(r,e,o){2==arguments.length&&(o=1);var s=function(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}(r,e),h=c(t(s,s));if(!h)return[1,0,0,0];var d=o*n(u(-1,i(1,t(r,e))))/2,M=f(d);return[a(d),s[2]/h*M,-s[1]/h*M,s[0]/h*M]},d.multiply=function(t,n){return[t[0]*n[0]-t[1]*n[1]-t[2]*n[2]-t[3]*n[3],t[0]*n[1]+t[1]*n[0]+t[2]*n[3]-t[3]*n[2],t[0]*n[2]-t[1]*n[3]+t[2]*n[0]+t[3]*n[1],t[0]*n[3]+t[1]*n[2]-t[2]*n[1]+t[3]*n[0]]},d});
(function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.versor=n()})(this,function(){"use strict";var c=Math.acos,n=Math.asin,e=Math.atan2,s=Math.cos,h=Math.max,d=Math.min,t=Math.PI,M=Math.sin,l=Math.sqrt,m=t/180,r=180/t,a=function(t){var n=t[0]/2*m,e=M(n),r=s(n),a=t[1]/2*m,i=M(a),o=s(a),u=t[2]/2*m,f=M(u),c=s(u);return[r*o*c+e*i*f,e*o*c-r*i*f,r*i*c+e*o*f,r*o*f-e*i*c]};function p(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}return a.cartesian=function(t){var n=t[0]*m,e=t[1]*m,r=s(e);return[r*s(n),r*M(n),M(e)]},a.rotation=function(t){return[e(2*(t[0]*t[1]+t[2]*t[3]),1-2*(t[1]*t[1]+t[2]*t[2]))*r,n(h(-1,d(1,2*(t[0]*t[2]-t[3]*t[1]))))*r,e(2*(t[0]*t[3]+t[1]*t[2]),1-2*(t[2]*t[2]+t[3]*t[3]))*r]},a.delta=function(t,n,e){2==arguments.length&&(e=1);var r,a,i=(a=n,[(r=t)[1]*a[2]-r[2]*a[1],r[2]*a[0]-r[0]*a[2],r[0]*a[1]-r[1]*a[0]]),o=l(p(i,i));if(!o)return[1,0,0,0];var u=e*c(h(-1,d(1,p(t,n))))/2,f=M(u);return[s(u),i[2]/o*f,-i[1]/o*f,i[0]/o*f]},a.multiply=function(t,n){return[t[0]*n[0]-t[1]*n[1]-t[2]*n[2]-t[3]*n[3],t[0]*n[1]+t[1]*n[0]+t[2]*n[3]-t[3]*n[2],t[0]*n[2]-t[1]*n[3]+t[2]*n[0]+t[3]*n[1],t[0]*n[3]+t[1]*n[2]-t[2]*n[1]+t[3]*n[0]]},a});

@@ -1,26 +0,14 @@

Copyright (c) 2013-2017, Michael Bostock
All rights reserved.
Copyright (c) 2013-2018, Michael Bostock
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* The name Michael Bostock may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
{
"name": "versor",
"version": "0.0.3",
"version": "0.0.4",
"description": "Versor",

@@ -11,3 +11,3 @@ "keywords": [

],
"license": "MIT",
"license": "GPL-3.0",
"main": "build/versor.js",

@@ -35,7 +35,7 @@ "unpkg": "build/versor.min.js",

"devDependencies": {
"package-preamble": "0.1",
"rollup": "0.49",
"tape": "4",
"uglify-js": "*"
"package-preamble": "0.1.0",
"rollup": "0.66.6",
"tape": "4.9.1",
"uglify-js": "3.4.9"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc