本文整理汇总了C++中tgStructure类的典型用法代码示例。如果您正苦于以下问题:C++ tgStructure类的具体用法?C++ tgStructure怎么用?C++ tgStructure使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了tgStructure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addChildRotation
void TensegrityModel::addChildRotation(tgStructure& childStructure, const Yam& rotation) {
if (!rotation) return;
Yam reference = rotation["reference"];
Yam axis = rotation["axis"];
Yam angle = rotation["angle"];
if (axis && angle) {
double axisX = axis[0].as<double>();
double axisY = axis[1].as<double>();
double axisZ = axis[2].as<double>();
btVector3 axisVector = btVector3(axisX, axisY, axisZ);
double angleDegrees = angle.as<double>();
double angleRadians = tgUtil::deg2rad(angleDegrees);
btVector3 referenceVector;
if (reference) {
// rotate child around provided reference point
double referenceX = reference[0].as<double>();
double referenceY = reference[1].as<double>();
double referenceZ = reference[2].as<double>();
referenceVector = btVector3(referenceX, referenceY, referenceZ);
}
else {
// rotate child around structure's centroid
referenceVector = childStructure.getCentroid();
}
childStructure.addRotation(referenceVector, axisVector, angleRadians);
}
}
示例2: addRodsLeg
void BigDoxieNoFeet::addRodsLeg(tgStructure& s){
s.addPair(0,1,"rod");
s.addPair(1,2,"rod");
s.addPair(1,3,"rod");
s.addPair(1,4,"rod");
s.addPair(0,5,"rod");
}
示例3: addNodesVertebra
void BigPuppySymmetricArching::addNodesVertebra(tgStructure& s, double r) {
s.addNode(0,0,0); //Node 0
s.addNode(r,0,r); //Node 1
s.addNode(r,0,-r); //Node 2
s.addNode(-r,0,-r); //Node 3
s.addNode(-r,0,r); //Node 4
}
示例4: rotateAndTranslate
/// @todo should use a best fit transformation from one set of points to another
void TensegrityModel::rotateAndTranslate(tgStructure& childStructure2,
std::vector<btVector3>& structure1RefNodes, std::vector<btVector3>& structure2RefNodes) {
btVector3 structure1RefNodesCentroid = tgUtil::getCentroid(structure1RefNodes);
btVector3 structure2RefNodesCentroid = tgUtil::getCentroid(structure2RefNodes);
btVector3 structure1PlaneNormal = ((structure1RefNodes[1] - structure1RefNodes[0]).
cross(structure1RefNodes[2] - structure1RefNodes[0])).normalize();
btVector3 structure2PlaneNormal = ((structure2RefNodes[1] - structure2RefNodes[0]).
cross(structure2RefNodes[2] - structure2RefNodes[0])).normalize();
// rotate structure 2 to align normals
btVector3 fallBackAxis = (structure2RefNodes[1] - structure2RefNodes[0]).normalize();
childStructure2.addRotation(structure2RefNodesCentroid,
tgUtil::getQuaternionBetween(structure2PlaneNormal, structure1PlaneNormal, fallBackAxis));
// rotate structure 2 ref nodes
tgUtil::addRotation(structure2RefNodes[0], structure2RefNodesCentroid,
tgUtil::getQuaternionBetween(structure2PlaneNormal, structure1PlaneNormal, fallBackAxis));
tgUtil::addRotation(structure2RefNodesCentroid, structure2RefNodesCentroid,
tgUtil::getQuaternionBetween(structure2PlaneNormal, structure1PlaneNormal, fallBackAxis));
// translate structure 2 to match up centroid points
childStructure2.move(structure1RefNodesCentroid - structure2RefNodesCentroid);
// translate structure 2 ref nodes
structure2RefNodes[0] += structure1RefNodesCentroid - structure2RefNodesCentroid;
structure2RefNodesCentroid += structure1RefNodesCentroid - structure2RefNodesCentroid;
// rotate structure 2 around structure1PlaneNormal axis to match up node with edge midpoints
childStructure2.addRotation(structure1RefNodesCentroid,
tgUtil::getQuaternionBetween(structure2RefNodes[0] - structure1RefNodesCentroid,
structure1RefNodes[0] - structure1RefNodesCentroid, structure1PlaneNormal));
}
示例5: addRodsLeg
void BigPuppySymmetricSpiralSegments::addRodsLeg(tgStructure& s){
s.addPair(0,1,"rod");
s.addPair(1,2,"rod");
s.addPair(1,3,"rod");
s.addPair(1,4,"rod");
s.addPair(0,5,"rod");
}
示例6: addRodsLeg
void BigPuppySymmetricArching::addRodsLeg(tgStructure& s) {
s.addPair(0,1,"rod");
s.addPair(1,2,"rod");
s.addPair(1,3,"rod");
s.addPair(1,4,"rod");
s.addPair(0,5,"rod");
}
示例7: addNodesVertebra
void BigDoxieNoFeet::addNodesVertebra(tgStructure& s, double r){
s.addNode(0,0,0); //Node 0
s.addNode(r,0,r); //Node 1
s.addNode(r,0,-r); //Node 2
s.addNode(-r,0,-r); //Node 3
s.addNode(-r,0,r); //Node 4
}
示例8: addNodesLeg
void BigDoxieNoFeet::addNodesLeg(tgStructure& s, double r){
s.addNode(0,0,0); //0: Bottom Center of lower leg segment
s.addNode(0,r,0); //1: Center of lower leg segment
s.addNode(r,r,0); //2: Right of lower leg segment
s.addNode(-r,r,0); //3: Left of lower leg segment
s.addNode(0,2*r,0); //4: Top of lower leg segment
s.addNode(0,-r/2,0); //5: Leg segment extension for connections to foot.
}
示例9: addPairsB
void VerticalSpineModel::addPairsB(tgStructure& tetra)
{
tetra.addPair(0, 4, "rodB");
tetra.addPair(1, 4, "rodB");
tetra.addPair(2, 4, "rodB");
tetra.addPair(3, 4, "rodB");
}
示例10:
void T6Model::addRods(tgStructure& s)
{
s.addPair( 0, 1, "rod");
s.addPair( 2, 3, "rod");
s.addPair( 4, 5, "rod");
s.addPair( 6, 7, "rod");
s.addPair( 8, 9, "rod");
s.addPair(10, 11, "rod");
}
示例11: addRodsFoot
void BigPuppySymmetricArching::addRodsFoot(tgStructure& s) {
s.addPair(0,6,"rod");
s.addPair(1,7,"rod");
s.addPair(2,4,"rod");
s.addPair(3,5,"rod");
s.addPair(0,1,"rod");
s.addPair(0,3,"rod");
s.addPair(1,2,"rod");
s.addPair(2,3,"rod");
}
示例12:
void T12SuperBallPayload::addRods(tgStructure& s)
{
s.addPair( 0, 6, "r1 rod");
s.addPair( 1, 7, "r2 rod");
s.addPair( 2, 8, "r3 rod");
s.addPair( 3, 4, "r4 rod");
s.addPair( 5, 11, "r5 rod");
s.addPair( 9, 10, "r6 rod");
}
示例13: addNodes
void DuCTTTestModel::addNodes(tgStructure& tetra, double edge, double height)
{
// right
tetra.addNode(-edge / 2.0, 0, tgUtil::round(std::sqrt(3.0) / 2.0 * height));
// left
tetra.addNode( edge / 2.0, 0, tgUtil::round(std::sqrt(3.0) / 2.0 * height));
// front
tetra.addNode(0, edge/2.0, 0);
// back
tetra.addNode(0, -edge/2.0, 0);
}
示例14: structureAttributeKeysVector
void TensegrityModel::addChildren(tgStructure& structure, const std::string& structurePath, tgBuildSpec& spec, const Yam& children) {
if (!children) return;
std::string structureAttributeKeys[] = {"path", "rotation", "translation", "scale", "offset"};
std::vector<std::string> structureAttributeKeysVector(structureAttributeKeys, structureAttributeKeys + sizeof(structureAttributeKeys) / sizeof(std::string));
// add all the children first
for (YAML::const_iterator child = children.begin(); child != children.end(); ++child) {
Yam childAttributes = child->second;
yamlContainsOnly(childAttributes, structurePath, structureAttributeKeysVector);
// multiple children can be defined using the syntax: child1/child2/child3...
// (add a slash so that each child is a string with a its name and a slash at the end)
std::string childCombos = child->first.as<std::string>() + "/";
while (childCombos.find("/") != std::string::npos) {
std::string childName = childCombos.substr(0, childCombos.find("/"));
addChild(structure, structurePath, childName, childAttributes["path"], spec);
childCombos = childCombos.substr(childCombos.find("/") + 1);
}
}
// apply rotation attribute to children
for (YAML::const_iterator child = children.begin(); child != children.end(); ++child) {
Yam childAttributes = child->second;
// multiple children can be defined using the syntax: child1/child2/child3...
// (add a slash so that each child is a string with a its name and a slash at the end)
std::string childCombos = child->first.as<std::string>() + "/";
while (childCombos.find("/") != std::string::npos) {
std::string childName = childCombos.substr(0, childCombos.find("/"));
tgStructure& childStructure = structure.findChild(childName);
addChildRotation(childStructure, childAttributes["rotation"]);
childCombos = childCombos.substr(childCombos.find("/") + 1);
}
}
// apply scale, offset and translation attributes to children
for (YAML::const_iterator child = children.begin(); child != children.end(); ++child) {
Yam childAttributes = child->second;
// multiple children can be defined using the syntax: child1/child2/child3...
// (add a slash so that each child is a string with a its name and a slash at the end)
std::string childCombos = child->first.as<std::string>() + "/";
int childComboIndex = 0;
while (childCombos.find("/") != std::string::npos) {
std::string childName = childCombos.substr(0, childCombos.find("/"));
tgStructure& childStructure = structure.findChild(childName);
addChildScale(childStructure, childAttributes["scale"]);
addChildOffset(childStructure, childComboIndex, childAttributes["offset"]);
addChildTranslation(childStructure, childAttributes["translation"]);
childCombos = childCombos.substr(childCombos.find("/") + 1);
childComboIndex++;
}
}
}
示例15: addNodes
void VerticalSpineModel::addNodes(tgStructure& tetra, double edge, double height)
{
// right
tetra.addNode( c.edge / 2.0, 0, 0); // node 0
// left
tetra.addNode( -c.edge / 2.0, 0, 0); // node 1
// top
tetra.addNode(0, c.height, -edge / 2.0); // node 2
// front
tetra.addNode(0, c.height, edge / 2.0); // node 3
// middle
tetra.addNode(0, c.height/2, 0); // node 4
}