UNPKG

@openhps/core

Version:

Open Hybrid Positioning System - Core component

38 lines (37 loc) 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.QuaternionLinearInterpolant = void 0; var _Interpolant = require("../Interpolant.js"); var _Quaternion = require("../Quaternion.js"); /** * Spherical linear unit quaternion interpolant. * * @augments Interpolant */ class QuaternionLinearInterpolant extends _Interpolant.Interpolant { /** * Constructs a new SLERP interpolant. * * @param {TypedArray} parameterPositions - The parameter positions hold the interpolation factors. * @param {TypedArray} sampleValues - The sample values. * @param {number} sampleSize - The sample size * @param {TypedArray} [resultBuffer] - The result buffer. */ constructor(parameterPositions, sampleValues, sampleSize, resultBuffer) { super(parameterPositions, sampleValues, sampleSize, resultBuffer); } interpolate_(i1, t0, t, t1) { const result = this.resultBuffer, values = this.sampleValues, stride = this.valueSize, alpha = (t - t0) / (t1 - t0); let offset = i1 * stride; for (let end = offset + stride; offset !== end; offset += 4) { _Quaternion.Quaternion.slerpFlat(result, 0, values, offset - stride, values, offset, alpha); } return result; } } exports.QuaternionLinearInterpolant = QuaternionLinearInterpolant;