1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Update Circle.cpp

This commit is contained in:
Sandu Liviu Catalin 2021-08-18 21:55:01 +03:00
parent 2fb0f851c0
commit a36e85d9b7

View File

@ -476,16 +476,16 @@ Array Circle::ToPointsArray(SQInteger num_segments) const
if (i >= num_segments) return false; if (i >= num_segments) return false;
// Get the current angle // Get the current angle
#ifdef SQUSEDOUBLE #ifdef SQUSEDOUBLE
SQFloat theta = 2.0d * SQMOD_PI64 * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments); SQFloat theta = 2.0 * SQMOD_PI64 * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
#else #else
SQFloat theta = 2.0f * SQMOD_PI * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments); SQFloat theta = 2.0f * SQMOD_PI * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
#endif // SQUSEDOUBLE #endif // SQUSEDOUBLE
// Calculate the x component // Calculate the x component
SQFloat x = (rad * cosf(theta)) + pos.x; SQFloat x = (rad * SQMOD_DOUBLE_OR(cos, cosf)(theta)) + pos.x;
// Calculate the y component // Calculate the y component
SQFloat y = (rad * sinf(theta)) + pos.y; SQFloat y = (rad * SQMOD_DOUBLE_OR(sin, sinf)(theta)) + pos.y;
// Push the Vector2 instance on the stack // Push the Vector2 instance on the stack
Var< Vector2 >::push(vm, Vector2{x, y}); Var< Vector2 >::push(vm, Vector2{static_cast< Vector2::Value >(x), static_cast< Vector2::Value >(y)});
// Insert the element on the stack into the array // Insert the element on the stack into the array
return true; return true;
}, num_segments); }, num_segments);