39 #include <std_msgs/ColorRGBA.h> 49 max = std::numeric_limits<float>::min();
50 min = std::numeric_limits<float>::max();
55 if (max < costs[vH] && std::isfinite(costs[vH]))
57 if (min > costs[vH] && std::isfinite(costs[vH]))
64 return Vector(p.x, p.y, p.z);
75 tf2::Vector3 tf_origin(position.
x, position.
y, position.
z);
81 geometry_msgs::Pose pose;
95 const Vector direction = next - current;
101 const float& epsilon)
104 std::array<float, 3> barycentric_coords;
110 return vec - (normal * (vec.
dot(normal) - (ref.
dot(normal))));
114 std::array<float, 3>& barycentric_coords)
121 std::array<float, 3>& barycentric_coords,
float& dist)
123 const Vector& a = vertices[0];
124 const Vector& b = vertices[1];
125 const Vector& c = vertices[2];
133 float oneOver4ASquared = 1.0 / n.
dot(n);
135 const float gamma = u.
cross(w).
dot(n) * oneOver4ASquared;
137 const float beta = w.
cross(v).
dot(n) * oneOver4ASquared;
138 const float alpha = 1 - gamma - beta;
140 barycentric_coords = { alpha, beta, gamma };
145 return ((0 - EPSILON <= alpha) && (alpha <= 1 + EPSILON) && (0 - EPSILON <= beta) && (beta <= 1 + EPSILON) &&
146 (0 - EPSILON <= gamma) && (gamma <= 1 + EPSILON));
149 std_msgs::ColorRGBA
color(
const float& r,
const float& g,
const float& b,
const float& a)
151 std_msgs::ColorRGBA
color;
168 float denom = N.
dot(N);
176 C = edge0.
cross(vp0);
183 C = edge1.
cross(vp1);
184 if ((u = N.
dot(C)) < 0)
190 C = edge2.
cross(vp2);
191 if ((v = N.
dot(C)) < 0)
203 if (!std::isfinite(value))
204 return std_msgs::ColorRGBA();
205 std_msgs::ColorRGBA
color;
213 value = std::min(value, 1.0
f);
214 value = std::max(value, 0.0
f);
216 float h = value * 5.0f + 1.0f;
239 tf2::Vector3 v = transform.getBasis() * axis;
246 return mesh_map::Vector(pose.pose.position.x, pose.pose.position.y, pose.pose.position.z);
std_msgs::ColorRGBA getRainbowColor(const float value)
map value to color on color rainbow
bool barycentricCoords(const Vector &p, const Vector &v0, const Vector &v1, const Vector &v2, float &u, float &v, float &w)
Computes the barycentric coordinates u, v,q of a query point p onto the triangle v0, v1, v2.
Vector toVector(const geometry_msgs::Point &point)
Converts a ROS geometry_msgs/Point message to a lvr2 vector.
lvr2::Normal< float > Normal
use normals with datatype float
BaseVector< CoordT > cross(const BaseVector &other) const
bool projectedBarycentricCoords(const Vector &p, const std::array< Vector, 3 > &vertices, std::array< float, 3 > &barycentric_coords, float &dist)
Computes projected barycentric coordinates and whether the query point lies inside or outside the giv...
mesh_map::Normal poseToDirectionVector(const geometry_msgs::PoseStamped &pose, const tf2::Vector3 &axis=tf2::Vector3(1, 0, 0))
void getMinMax(const lvr2::VertexMap< float > &map, float &min, float &max)
Function to compute the minimum and maximum of a cost layer.
Normal< CoordT > normalized() const
Vector projectVectorOntoPlane(const Vector &vec, const Vector &ref, const Normal &normal)
Projects a vector / point onto a plane, which is defined by the reference vector and the normal vecto...
void fromMsg(const A &, B &b)
geometry_msgs::Pose calculatePoseFromPosition(const Vector ¤t, const Vector &next, const Normal &normal)
Calculates a geometry_msgs/Pose message from two positions and a normal vector.
lvr2::BaseVector< float > Vector
use vectors with datatype folat
mesh_map::Vector poseToPositionVector(const geometry_msgs::PoseStamped &pose)
std_msgs::ColorRGBA color(const float &r, const float &g, const float &b, const float &a=1.0)
Function to build std_msgs color instances.
CoordT dot(const BaseVector &other) const
geometry_msgs::Pose calculatePoseFromDirection(const Vector &position, const Vector &direction, const Normal &normal)
bool inTriangle(const Vector &p, const Vector &v0, const Vector &v1, const Vector &v2, const float &max_dist, const float &epsilon)
Computes whether a points lies inside or outside a triangle with respect to a maximum distance while ...