MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / GetAngle

Function GetAngle

editor/HRoom.cpp:2447–2461  ·  view source on GitHub ↗

Gets the angle between two vectors in the range 0..1 Parameters: base - the start of both vectors v0,v1 - the end points of the two vectors normal - the surface normal of the face these verts lie in Returns the cosine of the angle between and

Source from the content-addressed store, hash-verified

2445// normal - the surface normal of the face these verts lie in
2446// Returns the cosine of the angle between <base,v0> and <base,v1>
2447float GetAngle(vector *base, vector *v0, vector *v1, vector *normal) {
2448 vector edge0, edge1, cross;
2449 float dot;
2450
2451 vm_GetNormalizedDir(&edge0, v0, base);
2452 vm_GetNormalizedDir(&edge1, v1, base);
2453
2454 dot = edge0 * edge1;
2455 cross = edge0 ^ edge1;
2456
2457 if (cross * *normal > 0)
2458 return 0.25 - dot / 4.0;
2459 else
2460 return 0.75 + dot / 4.0;
2461}
2462
2463// Connects two rooms in a pleasing way
2464void BuildSmoothBridge(room *rp0, int facenum0, room *rp1, int facenum1) {

Callers 1

BuildSmoothBridgeFunction · 0.85

Calls 1

vm_GetNormalizedDirFunction · 0.50

Tested by

no test coverage detected