Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 928d8e5

Browse files
committed
Update Vector source
1 parent ebcce19 commit 928d8e5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

System/Vector.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace RTE {
3434

3535
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3636

37-
Vector & Vector::SetMagnitude(float newMag) {
37+
Vector & Vector::SetMagnitude(const float newMag) {
3838
if (IsZero()) {
3939
SetXY(newMag, 0.0F);
4040
} else {
@@ -45,7 +45,7 @@ namespace RTE {
4545

4646
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4747

48-
Vector & Vector::CapMagnitude(float capMag) {
48+
Vector & Vector::CapMagnitude(const float capMag) {
4949
if (capMag == 0) { Reset(); }
5050
if (GetMagnitude() > capMag) { SetMagnitude(capMag); }
5151
return *this;
@@ -60,12 +60,12 @@ namespace RTE {
6060

6161
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6262

63-
Vector & Vector::RadRotate(float angle) {
64-
angle = -angle;
65-
const float tempX = m_X * std::cos(angle) - m_Y * std::sin(angle);
66-
const float tempY = m_X * std::sin(angle) + m_Y * std::cos(angle);
67-
m_X = tempX;
68-
m_Y = tempY;
63+
Vector & Vector::RadRotate(const float angle) {
64+
const float adjustedAngle = -angle;
65+
const float newX = m_X * std::cos(adjustedAngle) - m_Y * std::sin(adjustedAngle);
66+
const float newY = m_X * std::sin(adjustedAngle) + m_Y * std::cos(adjustedAngle);
67+
m_X = newX;
68+
m_Y = newY;
6969

7070
return *this;
7171
}

0 commit comments

Comments
 (0)