MCPcopy Create free account
hub / github.com/admtrv/objcurses / is_in_triangle

Function is_in_triangle

utils/algorithms.cpp:9–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7// helper functions
8
9static bool is_in_triangle(const Vec3 &pt, const Vec3 &v1, const Vec3 &v2, const Vec3 &v3, const Vec3 &normal)
10{
11 const float s1 = Vec3::dot(Vec3::cross(v2 - v1, pt - v1), normal);
12 const float s2 = Vec3::dot(Vec3::cross(v3 - v2, pt - v2), normal);
13 const float s3 = Vec3::dot(Vec3::cross(v1 - v3, pt - v3), normal);
14
15 const bool same_sign = (s1 >= 0 && s2 >= 0 && s3 >= 0) || (s1 <= 0 && s2 <= 0 && s3 <= 0);
16
17 return same_sign;
18}
19
20static bool is_ear(const size_t i, const std::vector<Vec3> &points, const std::vector<size_t> &indices, const Vec3 &normal)
21{

Callers 1

is_earFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected