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

Function CreateTwoVectorFrame

src/celengine/parseobject.cpp:1538–1612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1536
1537
1538static TwoVectorFrame*
1539CreateTwoVectorFrame(const Universe& universe,
1540 Hash* frameData,
1541 const Selection& defaultCenter)
1542{
1543 Selection center = getFrameCenter(universe, frameData, defaultCenter);
1544 if (center.empty())
1545 return NULL;
1546
1547 // Primary and secondary vector definitions are required
1548 Value* primaryValue = frameData->getValue("Primary");
1549 if (!primaryValue)
1550 {
1551 clog << "Primary axis missing from two-vector frame.\n";
1552 return NULL;
1553 }
1554
1555 Hash* primaryData = primaryValue->getHash();
1556 if (!primaryData)
1557 {
1558 clog << "Bad syntax for primary axis of two-vector frame.\n";
1559 return NULL;
1560 }
1561
1562 Value* secondaryValue = frameData->getValue("Secondary");
1563 if (!secondaryValue)
1564 {
1565 clog << "Secondary axis missing from two-vector frame.\n";
1566 return NULL;
1567 }
1568
1569 Hash* secondaryData = secondaryValue->getHash();
1570 if (!secondaryData)
1571 {
1572 clog << "Bad syntax for secondary axis of two-vector frame.\n";
1573 return NULL;
1574 }
1575
1576 // Get and validate the axes for the direction vectors
1577 int primaryAxis = getAxis(primaryData);
1578 int secondaryAxis = getAxis(secondaryData);
1579
1580 assert(abs(primaryAxis) <= 3);
1581 assert(abs(secondaryAxis) <= 3);
1582 if (primaryAxis == 0 || secondaryAxis == 0)
1583 {
1584 return NULL;
1585 }
1586
1587 if (abs(primaryAxis) == abs(secondaryAxis))
1588 {
1589 clog << "Bad two-vector frame: axes for vectors are collinear.\n";
1590 return NULL;
1591 }
1592
1593 FrameVector* primaryVector = CreateFrameVector(universe,
1594 center,
1595 primaryData);

Callers 1

CreateComplexFrameFunction · 0.85

Calls 7

getFrameCenterFunction · 0.85
getAxisFunction · 0.85
CreateFrameVectorFunction · 0.85
getHashMethod · 0.80
absFunction · 0.50
emptyMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected