DART  6.10.1
ArrowShape.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2021, 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  struct Properties
45  {
54  Properties(
55  double _radius = 0.01,
56  double _headRadiusScale = 2.0,
57  double _headLengthScale = 0.15,
58  double _minHeadLength = 0,
59  double _maxHeadLength = INFINITY,
60  bool _doubleArrow = false);
61 
62  double mRadius;
68  };
69 
72  ArrowShape(
73  const Eigen::Vector3d& _tail,
74  const Eigen::Vector3d& _head,
75  const Properties& _properties = Properties(),
76  const Eigen::Vector4d& _color = Eigen::Vector4d(0.5, 0.5, 1.0, 1.0),
77  std::size_t _resolution = 10);
78 
81  void setPositions(const Eigen::Vector3d& _tail, const Eigen::Vector3d& _head);
82 
84  const Eigen::Vector3d& getTail() const;
85 
87  const Eigen::Vector3d& getHead() const;
88 
90  void setProperties(const Properties& _properties);
91 
93  void notifyColorUpdated(const Eigen::Vector4d& _color) override;
94 
96  const Properties& getProperties() const;
97 
98  void configureArrow(
99  const Eigen::Vector3d& _tail,
100  const Eigen::Vector3d& _head,
101  const Properties& _properties);
102 
103 protected:
104  void instantiate(std::size_t resolution);
105 
106  Eigen::Vector3d mTail;
107  Eigen::Vector3d mHead;
108 
110 };
111 
112 } // namespace dynamics
113 } // namespace dart
114 
115 #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:101
void setProperties(const Properties &_properties)
Set the properties of this arrow.
Definition: ArrowShape.cpp:95
const Eigen::Vector3d & getTail() const
Get the location of the tail of this arrow.
Definition: ArrowShape.cpp:83
Properties mProperties
Definition: ArrowShape.hpp:109
const Eigen::Vector3d & getHead() const
Get the location of the head of this arrow.
Definition: ArrowShape.cpp:89
const Properties & getProperties() const
Get the properties of this arrow.
Definition: ArrowShape.cpp:115
Eigen::Vector3d mTail
Definition: ArrowShape.hpp:106
Eigen::Vector3d mHead
Definition: ArrowShape.hpp:107
void instantiate(std::size_t resolution)
Definition: ArrowShape.cpp:257
void configureArrow(const Eigen::Vector3d &_tail, const Eigen::Vector3d &_head, const Properties &_properties)
Definition: ArrowShape.cpp:176
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:58
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:76
Definition: MeshShape.hpp:47
Definition: BulletCollisionDetector.cpp:65
Definition: ArrowShape.hpp:45
double mMaxHeadLength
Definition: ArrowShape.hpp:66
double mRadius
Definition: ArrowShape.hpp:62
double mHeadLengthScale
Definition: ArrowShape.hpp:64
bool mDoubleArrow
Definition: ArrowShape.hpp:67
double mMinHeadLength
Definition: ArrowShape.hpp:65
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:63