NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgPair.cpp
Go to the documentation of this file.
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 
27 #include "tgPair.h"
28 
29 #include "tgUtil.h"
30 
31 
32 tgPair::tgPair() : tgTaggable() {}
33 
40 tgPair::tgPair(btVector3 from, btVector3 to) : m_pair(from, to), tgTaggable()
41 {}
42 
43 tgPair::tgPair(btVector3 from, btVector3 to, std::string tags) : m_pair(from, to), tgTaggable(tags)
44 {}
45 
52 btVector3& tgPair::getFrom()
53 {
54  assert(m_pair.first != NULL);
55  return m_pair.first;
56 }
57 
58 const btVector3& tgPair::getFrom() const
59 {
60  assert(m_pair.first != NULL);
61  return m_pair.first;
62 }
63 
68 void tgPair::setFrom(btVector3 from) { m_pair.first = from; }
69 
76 btVector3& tgPair::getTo()
77 {
78  assert(m_pair.second != NULL);
79  return m_pair.second;
80 }
81 
82 const btVector3& tgPair::getTo() const
83 {
84  assert(m_pair.second != NULL);
85  return m_pair.second;
86 }
87 
92 void tgPair::setTo(btVector3 to)
93 {
94  m_pair.second = to;
95 }
96 
97 void tgPair::addRotation(const btVector3& fixedPoint,
98  const btVector3& axis,
99  double angle)
100 {
101  tgUtil::addRotation(getFrom(), fixedPoint, axis, angle);
102  tgUtil::addRotation(getTo(), fixedPoint, axis, angle);
103 }
104 
105 void tgPair::addRotation(const btVector3& fixedPoint,
106  const btVector3& fromOrientation,
107  const btVector3& toOrientation)
108 {
109  tgUtil::addRotation(getFrom(), fixedPoint, fromOrientation, toOrientation);
110  tgUtil::addRotation(getTo(), fixedPoint, fromOrientation, toOrientation);
111 }
112 
113 void tgPair::addRotation(const btVector3& fixedPoint,
114  const btQuaternion& rotation)
115 {
116  tgUtil::addRotation(getFrom(), fixedPoint, rotation);
117  tgUtil::addRotation(getTo(), fixedPoint, rotation);
118 }
119 
120 void tgPair::move(const btVector3& offset)
121 {
122  m_pair.first += offset;
123  m_pair.second += offset;
124 }
125 
126 void tgPair::scale(const btVector3& referencePoint, double scaleFactor) {
127  m_pair.first.setX((m_pair.first.x() - referencePoint.x()) * scaleFactor + referencePoint.x());
128  m_pair.first.setY((m_pair.first.y() - referencePoint.y()) * scaleFactor + referencePoint.y());
129  m_pair.first.setZ((m_pair.first.z() - referencePoint.z()) * scaleFactor + referencePoint.z());
130 
131  m_pair.second.setX((m_pair.second.x() - referencePoint.x()) * scaleFactor + referencePoint.x());
132  m_pair.second.setY((m_pair.second.y() - referencePoint.y()) * scaleFactor + referencePoint.y());
133  m_pair.second.setZ((m_pair.second.z() - referencePoint.z()) * scaleFactor + referencePoint.z());
134 }
135 
std::pair< btVector3, btVector3 > m_pair
Definition: tgPair.h:127
Definition of class tgPair.
void setFrom(btVector3 from)
Definition: tgPair.cpp:68
Rand seeding simular to the evolution and terrain classes.
static void addRotation(btVector3 &v, const btVector3 &fixedPoint, const btVector3 &axis, double angle)
Definition: tgUtil.h:274
btVector3 & getTo()
Definition: tgPair.cpp:76
btVector3 & getFrom()
Definition: tgPair.cpp:52
void setTo(btVector3 to)
Definition: tgPair.cpp:92