MCPcopy Create free account
hub / github.com/CelestiaProject/Celestia / CreateFrameVector

Function CreateFrameVector

src/celengine/parseobject.cpp:1464–1535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1462
1463
1464static FrameVector*
1465CreateFrameVector(const Universe& universe,
1466 const Selection& center,
1467 Hash* vectorData)
1468{
1469 Value* value = NULL;
1470
1471 value = vectorData->getValue("RelativePosition");
1472 if (value != NULL && value->getHash() != NULL)
1473 {
1474 Hash* relPosData = value->getHash();
1475 Selection observer = getVectorObserver(universe, relPosData);
1476 Selection target = getVectorTarget(universe, relPosData);
1477 // Default observer is the frame center
1478 if (observer.empty())
1479 observer = center;
1480
1481 if (observer.empty() || target.empty())
1482 return NULL;
1483 else
1484 return new FrameVector(FrameVector::createRelativePositionVector(observer, target));
1485 }
1486
1487 value = vectorData->getValue("RelativeVelocity");
1488 if (value != NULL && value->getHash() != NULL)
1489 {
1490 Hash* relVData = value->getHash();
1491 Selection observer = getVectorObserver(universe, relVData);
1492 Selection target = getVectorTarget(universe, relVData);
1493 // Default observer is the frame center
1494 if (observer.empty())
1495 observer = center;
1496
1497 if (observer.empty() || target.empty())
1498 return NULL;
1499 else
1500 return new FrameVector(FrameVector::createRelativeVelocityVector(observer, target));
1501 }
1502
1503 value = vectorData->getValue("ConstantVector");
1504 if (value != NULL && value->getHash() != NULL)
1505 {
1506 Hash* constVecData = value->getHash();
1507 Vec3d vec(0.0, 0.0, 1.0);
1508 constVecData->getVector("Vector", vec);
1509 if (vec.length() == 0.0)
1510 {
1511 clog << "Bad two-vector frame: constant vector has length zero\n";
1512 return NULL;
1513 }
1514 vec.normalize();
1515 vec = Vec3d(vec.x, vec.z, -vec.y);
1516
1517 // The frame for the vector is optional; a NULL frame indicates
1518 // J2000 ecliptic.
1519 ReferenceFrame* f = NULL;
1520 Value* frameValue = constVecData->getValue("Frame");
1521 if (frameValue != NULL)

Callers 1

CreateTwoVectorFrameFunction · 0.85

Calls 10

getVectorObserverFunction · 0.85
getVectorTargetFunction · 0.85
Vec3dClass · 0.85
CreateReferenceFrameFunction · 0.85
getHashMethod · 0.80
getVectorMethod · 0.80
getValueMethod · 0.45
emptyMethod · 0.45
lengthMethod · 0.45
normalizeMethod · 0.45

Tested by

no test coverage detected