NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
AppRotationTest.cpp
1 /*
2  * Copyright © 2012, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The NASA Tensegrity Robotics Toolkit (NTRT) v1 platform is licensed
7  * under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * http://www.apache.org/licenses/LICENSE-2.0.
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
15  * either express or implied. See the License for the specific language
16  * governing permissions and limitations under the License.
17 */
18 
19 #include "tgcreator/tgNode.h"
20 #include "tgcreator/tgNodes.h"
21 #include "tgcreator/tgPair.h"
22 #include "tgcreator/tgPairs.h"
23 
24 void testNode(const btVector3& fixedPoint, const btVector3& axis, double angle)
25 {
26  tgNode n(0,1,0);
27 
28  std::cout << "[tgNode]:" << std::endl;
29  std::cout << "- before rotation: " << n << std::endl;
30 
31  n.addRotation(fixedPoint, axis, angle);
32 
33  std::cout << "- after rotation: " << n << std::endl;
34 }
35 
36 void testNodes(const btVector3& fixedPoint, const btVector3& axis, double angle)
37 {
38  std::cout << "[tgNodes]:" << std::endl;
39  tgNodes nodes;
40  nodes.addNode(0,0,0);
41  nodes.addNode(1,0,0);
42  nodes.addNode(0,1,0);
43  nodes.addNode(0,0,1);
44  nodes.addNode(1,1,1);
45 
46  std::cout << "- before rotation: " << nodes << std::endl;
47 
48  nodes.addRotation(fixedPoint, axis, angle);
49 
50  std::cout << "- after rotation: " << nodes << std::endl;
51 }
52 
53 void testPair(const btVector3& fixedPoint, const btVector3& axis, double angle)
54 {
55  tgPair p(tgNode(0,1,0), tgNode(1,0,1));
56 
57  std::cout << "[tgPair]:" << std::endl;
58  std::cout << "- before rotation: " << p << std::endl;
59 
60  p.addRotation(fixedPoint, axis, angle);
61 
62  std::cout << "- after rotation: " << p << std::endl;
63 }
64 
65 void testPairs(const btVector3& fixedPoint, const btVector3& axis, double angle)
66 {
67  std::cout << "[tgPairs]:" << std::endl;
68  tgNodes nodes;
69  nodes.addNode(0,0,0);
70  nodes.addNode(1,0,0);
71  nodes.addNode(0,1,0);
72  nodes.addNode(0,0,1);
73  nodes.addNode(1,1,1);
74  nodes.addNode(2,2,2);
75 
76  tgPairs pairs;
77  pairs.addPair(nodes.pair(0, 1));
78  pairs.addPair(nodes.pair(2, 3));
79  pairs.addPair(nodes.pair(4, 5));
80 
81  std::cout << "- before rotation: " << pairs << std::endl;
82 
83  pairs.addRotation(fixedPoint, axis, angle);
84 
85  std::cout << "- after rotation: " << pairs << std::endl;
86 }
87 
88 
89 
90 int main(int argc, char** argv)
91 {
92 
93  btVector3 fixedPoint(0,0,0);
94  btVector3 axis(1,0,0);
95  double angle = M_PI/2.0;
96 
97  std::cout << "Fixed point: " << fixedPoint << std::endl;
98  std::cout << "Axis: " << axis << std::endl;
99  std::cout << "Angle: " << angle << " radians" << std::endl;
100 
101  testNode(fixedPoint, axis, angle);
102  testNodes(fixedPoint, axis, angle);
103 
104  testPair(fixedPoint, axis, angle);
105  testPairs(fixedPoint, axis, angle);
106 
107 }
int main(int argc, char **argv)
tgPair pair(int from, int to, std::string tags="")
Definition: tgNodes.cpp:30
Definition of class tgPair.
Definition of class tgPairs.
Definition of class tgNodes.
Definition of class tgNode.
Definition: tgPair.h:48
Definition: tgNode.h:45
int addNode(const btVector3 &node)
Definition: tgNodes.h:129