Skip to content

Commit 69829e1

Browse files
Merge pull request #41 from DianaVasiliu/bianca
Added some comments
2 parents cd28769 + 44166d3 commit 69829e1

File tree

4 files changed

+3
-3
lines changed

4 files changed

+3
-3
lines changed

OpenRocket/OpenRocket/Rocket.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,18 @@ void Rocket::MarkKeyDown(int key, int x, int y) {
132132

133133
float dist(glm::vec4 pt, glm::vec4 p1, glm::vec4 p2)
134134
{
135+
// Calculate the Ox and Oy distances between the 2 points of the line segment.
135136
float dx = p2[0] - p1[0];
136137
float dy = p2[1] - p1[1];
137138
if ((dx == 0) && (dy == 0))
138139
{
139-
// It's a point not a line segment.
140140
dx = pt[0] - p1[0];
141141
dy = pt[1] - p1[1];
142142
return sqrt(dx * dx + dy * dy);
143143
}
144144

145-
// Calculate the t that minimizes the distance.
145+
// t is the relative distance between the point of projection of the point on the line segment.
146+
// We calculate the t that minimizez the distance between the point and the line segment.
146147
float t = ((pt[0] - p1[0]) * dx + (pt[1] - p1[1]) * dy) / (dx * dx + dy * dy);
147148

148149
// See if this represents one of the segment's
@@ -167,7 +168,6 @@ float dist(glm::vec4 pt, glm::vec4 p1, glm::vec4 p2)
167168
dy = pt[1] - closest[1];
168169
}
169170

170-
//cout << sqrt(dx * dx + dy * dy) << "\n";
171171
return sqrt(dx * dx + dy * dy);
172172
}
173173

OpenRocket/Screenshot_3.png

22.8 KB
Loading

OpenRocket/Screenshot_4.png

20 KB
Loading

OpenRocket/Screenshot_5.png

21.1 KB
Loading

0 commit comments

Comments
 (0)