NTRT Simulator  v1.1
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgPair.h
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 #ifndef TG_PAIR_H
28 #define TG_PAIR_H
29 
30 #include "core/tgTaggable.h"
31 
32 #include "LinearMath/btVector3.h"
33 
34 #include <string>
35 #include <iostream>
36 
37 class btQuaternion;
38 
48 class tgPair : public tgTaggable
49 {
50 public:
51 
52  tgPair();
53 
60  tgPair(btVector3 from, btVector3 to);
61 
62  tgPair(btVector3 from, btVector3 to, std::string tags);
63 
70  btVector3& getFrom();
71 
72  const btVector3& getFrom() const;
73 
78  void setFrom(btVector3 from);
79 
86  btVector3& getTo();
87 
88  const btVector3& getTo() const;
89 
94  void setTo(btVector3 to);
95 
96  void addRotation(const btVector3& fixedPoint,
97  const btVector3& axis,
98  double angle);
99 
100  void addRotation(const btVector3& fixedPoint,
101  const btVector3& fromOrientation,
102  const btVector3& toOrientation);
103 
104  void addRotation(const btVector3& fixedPoint,
105  const btQuaternion& rotation);
106 
107  // Note: without this, tgTaggables will throw a 'Most vexing parse' error
108  // @see http://en.wikipedia.org/wiki/Most_vexing_parse
109  // @todo: Should we also compare the tags here? I think not...
110  inline bool operator==(const tgPair& other) const
111  {
112  return (this->getFrom() == other.getFrom() && this->getTo() == other.getTo());
113  }
114 
115  void move(const btVector3& offset);
116 
117 protected:
118 
120  std::pair<btVector3, btVector3> m_pair;
121 };
122 
130 inline std::ostream&
131 operator<<(std::ostream& os, const tgPair& pair)
132 {
133  os << "tgPair(" << pair.getFrom() << ", " << pair.getTo()
134  << ", {" << pair.getTagStr(", ") << "})";
135  return os;
136 }
137 
138 
139 
140 #endif
std::pair< btVector3, btVector3 > m_pair
Definition: tgPair.h:120
std::ostream & operator<<(std::ostream &os, const tgPair &pair)
Definition: tgPair.h:131
Definition: tgPair.h:48
Contains the definition of class tgTaggable.
void setFrom(btVector3 from)
Definition: tgPair.cpp:68
btVector3 & getTo()
Definition: tgPair.cpp:76
btVector3 & getFrom()
Definition: tgPair.cpp:52
void setTo(btVector3 to)
Definition: tgPair.cpp:92