MCPcopy Create free account
hub / github.com/axmolengine/axmol / rotate

Method rotate

core/math/Vec2.cpp:186–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186void Vec2::rotate(const Vec2& point, float angle)
187{
188 float sinAngle = std::sin(angle);
189 float cosAngle = std::cos(angle);
190
191 if (point.isZero())
192 {
193 float tempX = x * cosAngle - y * sinAngle;
194 y = y * cosAngle + x * sinAngle;
195 x = tempX;
196 }
197 else
198 {
199 float tempX = x - point.x;
200 float tempY = y - point.y;
201
202 x = tempX * cosAngle - tempY * sinAngle + point.x;
203 y = tempY * cosAngle + tempX * sinAngle + point.y;
204 }
205}
206
207void Vec2::subtract(const Vec2& v1, const Vec2& v2, Vec2* dst)
208{

Callers 1

rotateByAngleMethod · 0.45

Calls 1

isZeroMethod · 0.45

Tested by

no test coverage detected