Skip to content

Commit

Permalink
Remove ability to use "null" as a reference frame.
Browse files Browse the repository at this point in the history
Supporting a "null" reference frame is unnecessary, since `new Entity()` without
a position property suffices as an arbitrary reference frame.
  • Loading branch information
speigg committed Jun 27, 2016
1 parent f68351b commit c862db8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Source/DataSources/OrientationProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ define([

function frameParents(frame) {
var frames = [];
while (defined(frame) && frame !== null) {
while (defined(frame)) {
frames.unshift(frame);
frame = frame.position && frame.position.referenceFrame;
}
Expand Down Expand Up @@ -132,7 +132,7 @@ define([
return Quaternion.clone(value, result);
}

if (inputFrame === null || outputFrame === null) {
if (!defined(inputFrame) || !defined(outputFrame)) {
return undefined;
}

Expand Down
4 changes: 2 additions & 2 deletions Source/DataSources/PositionProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ define([

function frameParents(frame) {
var frames = [];
while (defined(frame) && frame !== null) {
while (defined(frame)) {
frames.unshift(frame);
frame = frame.position && frame.position.referenceFrame;
}
Expand Down Expand Up @@ -162,7 +162,7 @@ define([
return Cartesian3.clone(value, result);
}

if (inputFrame === null || outputFrame === null) {
if (!defined(inputFrame) || !defined(outputFrame)) {
return undefined;
}

Expand Down
30 changes: 17 additions & 13 deletions Specs/DataSources/PositionPropertySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defineSuite([
//Results of the below tests were verified against STK Components.
var time = JulianDate.now();

it('Works with custom input referenceFrame without orientation', function() {
it('Works with entity input referenceFrame without orientation', function() {
var referenceFrame = new Entity();
referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000));

Expand All @@ -34,7 +34,7 @@ defineSuite([
expect(result).toEqual(new Cartesian3(100001, 200002, 300003));
});

it('Works with custom input referenceFrame with orientation', function() {
it('Works with entity input referenceFrame with orientation', function() {
var referenceFrame = new Entity();
referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000));
var orientation = new Quaternion(0, 0, 1, 1);
Expand All @@ -47,7 +47,7 @@ defineSuite([
expect(result).toEqual(new Cartesian3(99998, 200001, 300003));
});

it('Works with custom chained input reference', function() {
it('Works with custom chained input referenceFrame', function() {
var referenceFrame = new Entity();
referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000));
var orientation = new Quaternion(0, 0, 1, 1);
Expand All @@ -66,7 +66,7 @@ defineSuite([
expect(result).toEqual(new Cartesian3(99603, 200201, 300602));
});

it('Works with custom output referenceFrame without orientation', function() {
it('Works with entity output referenceFrame without orientation', function() {
var referenceFrame = new Entity();
referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000));

Expand All @@ -76,7 +76,7 @@ defineSuite([
expect(result).toEqual(new Cartesian3(1, 2, 3));
});

it('Works with custom output referenceFrame with orientation', function() {
it('Works with entity output referenceFrame with orientation', function() {
var referenceFrame = new Entity();
referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000));
var orientation = new Quaternion(0, 0, 1, 1);
Expand All @@ -89,7 +89,7 @@ defineSuite([
expect(result).toEqualEpsilon(new Cartesian3(1, 2, 3), CesiumMath.EPSILON7);
});

it('Works with custom chained output referenceFrame', function() {
it('Works with chained output referenceFrame', function() {
var referenceFrame = new Entity();
referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000));
var orientation = new Quaternion(0, 0, 1, 1);
Expand All @@ -108,7 +108,7 @@ defineSuite([
expect(result).toEqualEpsilon(new Cartesian3(1, 2, 3), CesiumMath.EPSILON7);
});

it('Works with custom input and output referenceFrames', function() {
it('Works with entity input and output referenceFrame parameters', function() {
var referenceFrame = new Entity();
referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000));
var orientation = new Quaternion(0, 0, 1, 1);
Expand All @@ -127,9 +127,11 @@ defineSuite([
expect(result).toEqualEpsilon(new Cartesian3(201, 397, 602), CesiumMath.EPSILON7);
});

it('Works with custom input and output referenceFrames and null root referenceFrame', function() {
it('Works when input and output referenceFrame parameters have a root entity reference frame', function() {
var rootFrame = new Entity();

var referenceFrame = new Entity();
referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000), null);
referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000), rootFrame);
var orientation = new Quaternion(0, 0, 1, 1);
Quaternion.normalize(orientation, orientation);
referenceFrame.orientation = new ConstantProperty(orientation);
Expand All @@ -141,20 +143,22 @@ defineSuite([
referenceFrame2.orientation = new ConstantProperty(orientation);

var value = new Cartesian3(1, 2, 3);
var result = PositionProperty.convertToReferenceFrame(time, value, referenceFrame2, referenceFrame);
var result = PositionProperty.convertToReferenceFrame(time, value, referenceFrame2, rootFrame);

expect(result).toEqualEpsilon(new Cartesian3(201, 397, 602), CesiumMath.EPSILON7);
expect(result).toEqualEpsilon(new Cartesian3(99603, 200201, 300602), CesiumMath.EPSILON7);
});

it('returns undefined when input and output referenceFrames are disconnected', function() {
var rootEntity = new Entity();
var referenceFrame = new Entity();
referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000), null);
referenceFrame.position = new ConstantPositionProperty(new Cartesian3(100000, 200000, 300000), rootEntity);
var orientation = new Quaternion(0, 0, 1, 1);
Quaternion.normalize(orientation, orientation);
referenceFrame.orientation = new ConstantProperty(orientation);

var rootEntity2 = new Entity();
var referenceFrame2 = new Entity();
referenceFrame2.position = new ConstantPositionProperty(new Cartesian3(200, 400, 600), null);
referenceFrame2.position = new ConstantPositionProperty(new Cartesian3(200, 400, 600), rootEntity2);
orientation = new Quaternion(1, 0, 0, 1);
Quaternion.normalize(orientation, orientation);
referenceFrame2.orientation = new ConstantProperty(orientation);
Expand Down

0 comments on commit c862db8

Please sign in to comment.