DART  6.7.3
ArrowShape.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2019, The DART development contributors
3  * All rights reserved.
4  *
5  * The list of contributors can be found at:
6  * https://github.com/dartsim/dart/blob/master/LICENSE
7  *
8  * This file is provided under the following "BSD-style" License:
9  * Redistribution and use in source and binary forms, with or
10  * without modification, are permitted provided that the following
11  * conditions are met:
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef DART_DYNAMICS_ARROWSHAPE_HPP_
34 #define DART_DYNAMICS_ARROWSHAPE_HPP_
35 
37 
38 namespace dart {
39 namespace dynamics {
40 
41 class ArrowShape : public MeshShape
42 {
43 public:
44 
45  struct Properties
46  {
55  Properties(double _radius=0.01, double _headRadiusScale=2.0,
56  double _headLengthScale=0.15,
57  double _minHeadLength=0, double _maxHeadLength=INFINITY,
58  bool _doubleArrow=false);
59 
60  double mRadius;
66  };
67 
70  ArrowShape(const Eigen::Vector3d& _tail, const Eigen::Vector3d& _head,
71  const Properties& _properties = Properties(),
72  const Eigen::Vector4d& _color=Eigen::Vector4d(0.5,0.5,1.0,1.0),
73  std::size_t _resolution=10);
74 
77  void setPositions(const Eigen::Vector3d& _tail, const Eigen::Vector3d& _head);
78 
80  const Eigen::Vector3d& getTail() const;
81 
83  const Eigen::Vector3d& getHead() const;
84 
86  void setProperties(const Properties& _properties);
87 
89  void notifyColorUpdated(const Eigen::Vector4d& _color) override;
90 
92  const Properties& getProperties() const;
93 
94  void configureArrow(const Eigen::Vector3d& _tail,
95  const Eigen::Vector3d& _head,
96  const Properties& _properties);
97 
98 protected:
99 
100  void instantiate(std::size_t resolution);
101 
102  Eigen::Vector3d mTail;
103  Eigen::Vector3d mHead;
104 
106 };
107 
108 } // namespace dynamics
109 } // namespace dart
110 
111 #endif // DART_DYNAMICS_ARROWSHAPE_HPP_
Definition: ArrowShape.hpp:42
void notifyColorUpdated(const Eigen::Vector4d &_color) override
Set the color of this arrow.
Definition: ArrowShape.cpp:98
void setProperties(const Properties &_properties)
Set the properties of this arrow.
Definition: ArrowShape.cpp:92
const Eigen::Vector3d & getTail() const
Get the location of the tail of this arrow.
Definition: ArrowShape.cpp:80
Properties mProperties
Definition: ArrowShape.hpp:105
const Eigen::Vector3d & getHead() const
Get the location of the head of this arrow.
Definition: ArrowShape.cpp:86
const Properties & getProperties() const
Get the properties of this arrow.
Definition: ArrowShape.cpp:112
Eigen::Vector3d mTail
Definition: ArrowShape.hpp:102
Eigen::Vector3d mHead
Definition: ArrowShape.hpp:103
void instantiate(std::size_t resolution)
Definition: ArrowShape.cpp:243
void configureArrow(const Eigen::Vector3d &_tail, const Eigen::Vector3d &_head, const Properties &_properties)
Definition: ArrowShape.cpp:165
ArrowShape(const Eigen::Vector3d &_tail, const Eigen::Vector3d &_head, const Properties &_properties=Properties(), const Eigen::Vector4d &_color=Eigen::Vector4d(0.5, 0.5, 1.0, 1.0), std::size_t _resolution=10)
This will produce an arrow that reaches from _tail to _head with the given properties.
Definition: ArrowShape.cpp:56
void setPositions(const Eigen::Vector3d &_tail, const Eigen::Vector3d &_head)
Set the positions of the tail and head of the arrow without changing any settings.
Definition: ArrowShape.cpp:73
Definition: MeshShape.hpp:53
Definition: BulletCollisionDetector.cpp:63
Definition: ArrowShape.hpp:46
double mMaxHeadLength
Definition: ArrowShape.hpp:64
double mRadius
Definition: ArrowShape.hpp:60
double mHeadLengthScale
Definition: ArrowShape.hpp:62
bool mDoubleArrow
Definition: ArrowShape.hpp:65
double mMinHeadLength
Definition: ArrowShape.hpp:63
Properties(double _radius=0.01, double _headRadiusScale=2.0, double _headLengthScale=0.15, double _minHeadLength=0, double _maxHeadLength=INFINITY, bool _doubleArrow=false)
_radius affects the thickness of the arrow.
Definition: ArrowShape.cpp:41
double mHeadRadiusScale
Definition: ArrowShape.hpp:61