NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
abstractMarker.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 "abstractMarker.h"
28 
29 abstractMarker::abstractMarker(){
30  // Supress compiler warning for bullet's unused variable
31  (void) btInfinityMask;
32 }
33 
34 //Place the marker to the current world position and attach it to the body.
35 abstractMarker::abstractMarker(const btRigidBody *body,btVector3 worldPos,btVector3 color,int nodeNumber)
36 {
37  attachedBody=body;
38  //find relative position
39  attachedRelativeOriginalPosition=worldPos;//Use local transform;
40  this->color = color;
41  this->nodeNumber = nodeNumber;
42 }
43 
44 //This returns current position relative to the rigidbody.
46 {
47  btTransform tr = attachedBody->getWorldTransform();
48  btVector3 worldPos = tr * attachedRelativeOriginalPosition;
49  return worldPos-this->attachedBody->getCenterOfMassPosition();
50 }
51 
52 //This returns current absolute position of the marker.
54 {
55  btTransform tr = attachedBody->getWorldTransform();
56  return tr * attachedRelativeOriginalPosition;
57 }
58 
btVector3 getRelativePosition() const
Markers for specific places on a tensegrity.
btVector3 getWorldPosition() const