123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- define([
- '../Core/Cartesian3',
- '../Core/defaultValue',
- '../Core/defined',
- '../Core/defineProperties',
- '../Core/DeveloperError',
- '../Core/Event',
- '../Core/ReferenceFrame',
- './PositionProperty',
- './Property',
- './SampledProperty'
- ], function(
- Cartesian3,
- defaultValue,
- defined,
- defineProperties,
- DeveloperError,
- Event,
- ReferenceFrame,
- PositionProperty,
- Property,
- SampledProperty) {
- "use strict";
-
- var SampledPositionProperty = function(referenceFrame, numberOfDerivatives) {
- numberOfDerivatives = defaultValue(numberOfDerivatives, 0);
- var derivativeTypes;
- if (numberOfDerivatives > 0) {
- derivativeTypes = new Array(numberOfDerivatives);
- for (var i = 0; i < numberOfDerivatives; i++) {
- derivativeTypes[i] = Cartesian3;
- }
- }
- this._numberOfDerivatives = numberOfDerivatives;
- this._property = new SampledProperty(Cartesian3, derivativeTypes);
- this._definitionChanged = new Event();
- this._referenceFrame = defaultValue(referenceFrame, ReferenceFrame.FIXED);
- this._property._definitionChanged.addEventListener(function() {
- this._definitionChanged.raiseEvent(this);
- }, this);
- };
- defineProperties(SampledPositionProperty.prototype, {
-
- isConstant : {
- get : function() {
- return this._property.isConstant;
- }
- },
-
- definitionChanged : {
- get : function() {
- return this._definitionChanged;
- }
- },
-
- referenceFrame : {
- get : function() {
- return this._referenceFrame;
- }
- },
-
- interpolationDegree : {
- get : function() {
- return this._property.interpolationDegree;
- }
- },
-
- interpolationAlgorithm : {
- get : function() {
- return this._property.interpolationAlgorithm;
- }
- },
-
- numberOfDerivatives : {
- get : function() {
- return this._numberOfDerivatives;
- }
- },
-
- forwardExtrapolationType : {
- get : function() {
- return this._property.forwardExtrapolationType;
- },
- set : function(value) {
- this._property.forwardExtrapolationType = value;
- }
- },
-
- forwardExtrapolationDuration : {
- get : function() {
- return this._property.forwardExtrapolationDuration;
- },
- set : function(value) {
- this._property.forwardExtrapolationDuration = value;
- }
- },
-
- backwardExtrapolationType : {
- get : function() {
- return this._property.backwardExtrapolationType;
- },
- set : function(value) {
- this._property.backwardExtrapolationType = value;
- }
- },
-
- backwardExtrapolationDuration : {
- get : function() {
- return this._property.backwardExtrapolationDuration;
- },
- set : function(value) {
- this._property.backwardExtrapolationDuration = value;
- }
- }
- });
-
- SampledPositionProperty.prototype.getValue = function(time, result) {
- return this.getValueInReferenceFrame(time, ReferenceFrame.FIXED, result);
- };
-
- SampledPositionProperty.prototype.getValueInReferenceFrame = function(time, referenceFrame, result) {
-
- if (!defined(time)) {
- throw new DeveloperError('time is required.');
- }
- if (!defined(referenceFrame)) {
- throw new DeveloperError('referenceFrame is required.');
- }
-
- result = this._property.getValue(time, result);
- if (defined(result)) {
- return PositionProperty.convertToReferenceFrame(time, result, this._referenceFrame, referenceFrame, result);
- }
- return undefined;
- };
-
- SampledPositionProperty.prototype.setInterpolationOptions = function(options) {
- this._property.setInterpolationOptions(options);
- };
-
- SampledPositionProperty.prototype.addSample = function(time, position, derivatives) {
- var numberOfDerivatives = this._numberOfDerivatives;
-
- if (numberOfDerivatives > 0 && (!defined(derivatives) || derivatives.length !== numberOfDerivatives)) {
- throw new DeveloperError('derivatives length must be equal to the number of derivatives.');
- }
-
- this._property.addSample(time, position, derivatives);
- };
-
- SampledPositionProperty.prototype.addSamples = function(times, positions, derivatives) {
- this._property.addSamples(times, positions, derivatives);
- };
-
- SampledPositionProperty.prototype.addSamplesPackedArray = function(data, epoch) {
- this._property.addSamplesPackedArray(data, epoch);
- };
-
- SampledPositionProperty.prototype.equals = function(other) {
- return this === other ||
- (Property.equals(this._property, other._property) &&
- this._referenceFrame === other._referenceFrame);
- };
- return SampledPositionProperty;
- });
|