Download pool/shard009/JavaScript/0056280_Transform.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 1.62 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard009/JavaScript/0056280_Transform.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard009/JavaScript/0056280_Transform.js
-
curl -L -o 0056280_Transform.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard009/JavaScript/0056280_Transform.js
1.62 kB
| /*var Vec3 = require('./Vec3'); | |
| var Quaternion = require('./Quaternion'); | |
| module.exports = Transform; | |
| */ | |
| /** | |
| * @class Transform | |
| * @constructor | |
| */ | |
| function Transform() { | |
| /** | |
| * @property {Vec3} position | |
| */ | |
| this.position = new CANNON.Vec3(); | |
| /** | |
| * @property {Quaternion} quaternion | |
| */ | |
| this.quaternion = new CANNON.Quaternion(); | |
| } | |
| var tmpQuat = new CANNON.Quaternion(); | |
| /** | |
| * @static | |
| * @method pointToLocaFrame | |
| * @param {Vec3} position | |
| * @param {Quaternion} quaternion | |
| * @param {Vec3} worldPoint | |
| * @param {Vec3} result | |
| */ | |
| Transform.pointToLocalFrame = function(position, quaternion, worldPoint, result){ | |
| var result = result || new CANNON.Vec3(); | |
| worldPoint.vsub(position, result); | |
| quaternion.conjugate(tmpQuat); | |
| tmpQuat.vmult(result, result); | |
| return result; | |
| }; | |
| /** | |
| * @static | |
| * @method pointToWorldFrame | |
| * @param {Vec3} position | |
| * @param {Vec3} quaternion | |
| * @param {Vec3} localPoint | |
| * @param {Vec3} result | |
| */ | |
| Transform.pointToWorldFrame = function(position, quaternion, localPoint, result){ | |
| var result = result || new CANNON.Vec3(); | |
| quaternion.vmult(localPoint, result); | |
| result.vadd(position, result); | |
| return result; | |
| }; | |
| Transform.prototype.vectorToWorldFrame = function(localVector, result){ | |
| var result = result || new CANNON.Vec3(); | |
| this.quaternion.vmult(localVector, result); | |
| return result; | |
| }; | |
| Transform.vectorToLocalFrame = function(position, quaternion, worldVector, result){ | |
| var result = result || new CANNON.Vec3(); | |
| quaternion.w *= -1; | |
| quaternion.vmult(worldVector, result); | |
| quaternion.w *= -1; | |
| return result; | |
| }; | |