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

Method normal

utils/mathematics.cpp:107–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107Vec3 Vec3::normal(const std::vector<Vec3> &polygon)
108{
109 Vec3 n(0.0f, 0.0f, 0.0f);
110
111 for (size_t i = 0; i < polygon.size(); i++)
112 {
113 const Vec3& a = polygon[i];
114 const Vec3& b = polygon[(i + 1) % polygon.size()];
115
116 n.x += (a.y - b.y) * (a.z + b.z);
117 n.y += (a.z - b.z) * (a.x + b.x);
118 n.z += (a.x - b.x) * (a.y + b.y);
119 }
120
121 return n;
122}
123
124Vec3 Vec3::to_screen(const Vec3 &v, float zoom, float logical_x, float logical_y)
125{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected