MCPcopy Create free account
hub / github.com/OpenBoardView/OpenBoardView / VHConvexHullOrientation

Function VHConvexHullOrientation

src/openboardview/vectorhulls.cpp:142–148  ·  view source on GitHub ↗

To find orientation of ordered triplet (p, q, r). The function returns following values 0 --> p, q and r are colinear 1 --> Clockwise 2 --> Counterclockwise

Source from the content-addressed store, hash-verified

140// 1 --> Clockwise
141// 2 --> Counterclockwise
142int VHConvexHullOrientation(ImVec2 p, ImVec2 q, ImVec2 r) {
143
144 int val = trunc(((q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y)));
145
146 if (val == 0) return 0; // colinear
147 return (val > 0) ? 1 : 2; // clock or counterclock wise
148}
149
150std::vector<ImVec2> VHConvexHull(const std::vector<ImVec2> &points) {
151 std::vector<ImVec2> hull;

Callers 1

VHConvexHullFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected