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