projects
/
physics.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactored Vector2
[physics.git]
/
src
/
mathw.cpp
diff --git
a/src/mathw.cpp
b/src/mathw.cpp
index
eda4781
..
2b71dec
100644
(file)
--- a/
src/mathw.cpp
+++ b/
src/mathw.cpp
@@
-39,31
+39,31
@@
Vector2 vectorToLine
float lineSize = (float) sqrt((x1 - x2) * (x1 - x2)
+ (y1 - y2) * (y1 - y2));
if (lineSize == 0)
float lineSize = (float) sqrt((x1 - x2) * (x1 - x2)
+ (y1 - y2) * (y1 - y2));
if (lineSize == 0)
- return Vector2(x1 - vec.
x, y1 - vec.y
);
+ return Vector2(x1 - vec.
m_fX, y1 - vec.m_fY
);
- float u = ((vec.
x
- x1) * (x2 - x1)
- + (vec.
y
- y1) * (y2 - y1)) / (lineSize * lineSize);
+ float u = ((vec.
m_fX
- x1) * (x2 - x1)
+ + (vec.
m_fY
- y1) * (y2 - y1)) / (lineSize * lineSize);
if (u < 0)
if (u < 0)
- return Vector2(x1 - vec.
x, y1 - vec.y
);
+ return Vector2(x1 - vec.
m_fX, y1 - vec.m_fY
);
else if (u > 1)
else if (u > 1)
- return Vector2(x2 - vec.
x, y2 - vec.y
);
+ return Vector2(x2 - vec.
m_fX, y2 - vec.m_fY
);
else
{
float ix = x1 + u * (x2 - x1);
float iy = y1 + u * (y2 - y1);
else
{
float ix = x1 + u * (x2 - x1);
float iy = y1 + u * (y2 - y1);
- return Vector2(ix - vec.
x, iy - vec.y
);
+ return Vector2(ix - vec.
m_fX, iy - vec.m_fY
);
}
}
Vector2 perp(const Vector2& vec)
{
}
}
Vector2 perp(const Vector2& vec)
{
- return Vector2(-vec.
y, vec.x
);
+ return Vector2(-vec.
m_fY, vec.m_fX
);
}
float dot(const Vector2& vec1, const Vector2& vec2)
{
}
float dot(const Vector2& vec1, const Vector2& vec2)
{
- return vec1.
x * vec2.x + vec1.y * vec2.y
;
+ return vec1.
m_fX * vec2.m_fX + vec1.m_fY * vec2.m_fY
;
}
//TODO float Vector2::projectionCoeff(const Vector2* vec) const;
}
//TODO float Vector2::projectionCoeff(const Vector2* vec) const;