How to use math - 10 common examples

To help you get started, we’ve selected a few math examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uber / deck.gl / test / modules / core / effects / lighting / sunlight.spec.js View on Github external
TEST_CASES.forEach(testCase => {
    const {azimuth, altitude} = getSolarPosition(testCase.timestamp, LATITUDE, LONGITUDE);
    // azimuth is measured from south to west, azimuth + 180 is converting to north to east
    const azimuthInDegree = 180 + (azimuth * 180) / Math.PI;
    const altitudeInDegree = (altitude * 180) / Math.PI;

    console.log(azimuthInDegree, testCase.azimuth, altitudeInDegree, testCase.altitude);

    t.ok(equals(azimuthInDegree, testCase.azimuth), 'Azimuth angle should match.');
    t.ok(equals(altitudeInDegree, testCase.altitude), 'Altitude angle should match.');
  });
github uber / deck.gl / test / modules / core / effects / lighting / sunlight.spec.js View on Github external
TEST_CASES.forEach(testCase => {
    const {azimuth, altitude} = getSolarPosition(testCase.timestamp, LATITUDE, LONGITUDE);
    // azimuth is measured from south to west, azimuth + 180 is converting to north to east
    const azimuthInDegree = 180 + (azimuth * 180) / Math.PI;
    const altitudeInDegree = (altitude * 180) / Math.PI;

    console.log(azimuthInDegree, testCase.azimuth, altitudeInDegree, testCase.altitude);

    t.ok(equals(azimuthInDegree, testCase.azimuth), 'Azimuth angle should match.');
    t.ok(equals(altitudeInDegree, testCase.altitude), 'Altitude angle should match.');
  });
github uber / deck.gl / modules / core / src / views / orthographic-view.js View on Github external
function getProjectionMatrix({width, height, near, far}) {
  // Make sure Matrix4.ortho doesn't crash on 0 width/height
  width = width || 1;
  height = height || 1;

  return new Matrix4().ortho({
    left: -width / 2,
    right: width / 2,
    bottom: height / 2,
    top: -height / 2,
    near,
    far
  });
}
github uber / luma.gl / modules / experimental / src / scenegraph / nodes / scenegraph-node.js View on Github external
constructor(props = {}) {
    const {id} = props;

    this.id = id || uid(this.constructor.name);

    this.display = true; // whether to display the object at all
    this.position = new Vector3();
    this.rotation = new Vector3();
    this.scale = new Vector3(1, 1, 1);
    this.matrix = new Matrix4();
    this.userData = {};

    this.props = {};
    this._setScenegraphNodeProps(props);
  }
github uber / luma.gl / modules / experimental / src / scenegraph / nodes / scenegraph-node.js View on Github external
constructor(props = {}) {
    const {id} = props;

    this.id = id || uid(this.constructor.name);

    this.display = true; // whether to display the object at all
    this.position = new Vector3();
    this.rotation = new Vector3();
    this.scale = new Vector3(1, 1, 1);
    this.matrix = new Matrix4();
    this.userData = {};

    this.props = {};
    this._setScenegraphNodeProps(props);
  }
github uber / luma.gl / modules / experimental / src / scenegraph / nodes / scenegraph-node.js View on Github external
constructor(props = {}) {
    const {id} = props;

    this.id = id || uid(this.constructor.name);

    this.display = true; // whether to display the object at all
    this.position = new Vector3();
    this.rotation = new Vector3();
    this.scale = new Vector3(1, 1, 1);
    this.matrix = new Matrix4();
    this.userData = {};

    this.props = {};
    this._setScenegraphNodeProps(props);
  }
github uber / luma.gl / modules / experimental / src / scenegraph / nodes / scenegraph-node.js View on Github external
constructor(props = {}) {
    const {id} = props;

    this.id = id || uid(this.constructor.name);

    this.display = true; // whether to display the object at all
    this.position = new Vector3();
    this.rotation = new Vector3();
    this.scale = new Vector3(1, 1, 1);
    this.matrix = new Matrix4();
    this.userData = {};

    this.props = {};
    this._setScenegraphNodeProps(props);
  }
github uber / deck.gl / src / core / viewports / viewport.js View on Github external
equals(viewport) {
    if (!(viewport instanceof Viewport)) {
      return false;
    }

    return (
      viewport.width === this.width &&
      viewport.height === this.height &&
      equals(viewport.projectionMatrix, this.projectionMatrix) &&
      equals(viewport.viewMatrix, this.viewMatrix)
    );
    // TODO - check distance scales?
  }
github uber / luma.gl / src / deprecated / scene.js View on Github external
getDirectionalUniforms(directional) {
    const {color, direction} = directional;

    // Normalize lighting direction vector
    const dir = new Vector3(direction.x, direction.y, direction.z)
      .normalize()
      .scale(-1, -1, -1);

    return {
      directionalColor: [color.r, color.g, color.b],
      lightingDirection: [dir.x, dir.y, dir.z]
    };
  }
github uber-web / math.gl / test / src / matrix4.spec.js View on Github external
test('Matrix4.toFloat32Array', t => {
  t.equals(typeof Matrix4.prototype.toFloat32Array, 'function');
  const m = new Matrix4();
  m.identity();
  t.equals(m.toFloat32Array().BYTES_PER_ELEMENT, 4);
  t.end();
});

math

Mathematical Functions

Unknown
Latest version published 13 years ago

Package Health Score

39 / 100
Full package analysis