Skip to content

Commit 2d035e9

Browse files
committed
removed redundant EdgeOrientation
1 parent 89064ab commit 2d035e9

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

include/dmsc/edge.hpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
namespace dmsc {
1010

11-
using EdgeOrientation = std::pair<glm::vec3, glm::vec3>;
12-
1311
class InterSatelliteLink {
1412
public:
1513
InterSatelliteLink(const uint32_t& v1_idx, const uint32_t& v2_idx, const std::vector<Satellite>& satellites,
@@ -70,22 +68,22 @@ class InterSatelliteLink {
7068
* @param t [sec] Time when the satellites have to face each other.
7169
*/
7270
bool canAlign(const TimelineEvent<glm::vec3>& sat1, const TimelineEvent<glm::vec3>& sat2, const float t) const {
73-
EdgeOrientation target = getOrientation(t);
71+
glm::vec3 target = getOrientation(t);
7472
float angle_sat1 = .0f;
7573
float angle_sat2 = .0f;
7674
float time_sat1 = .0f;
7775
float time_sat2 = .0f;
7876

7977
// calc angle between orientations; direction vectors must be length 1
8078
if (sat1.isValid()) {
81-
angle_sat1 = std::acos(glm::dot(sat1.data, target.first)); // [rad]
79+
angle_sat1 = std::acos(glm::dot(sat1.data, target)); // [rad]
8280
time_sat1 = sat1.t_begin;
8381
} else {
8482
time_sat1 = 0.f; // event is invalid, so assume that sat1 was not part of a communication yet
8583
}
8684

8785
if (sat2.isValid()) {
88-
angle_sat2 = std::acos(glm::dot(sat2.data, target.second)); // [rad]
86+
angle_sat2 = std::acos(glm::dot(sat2.data, -target)); // [rad]
8987
time_sat2 = sat2.t_begin;
9088
} else {
9189
time_sat2 = 0.f; // event is invalid, so assume that sat1 was not part of a communication yet
@@ -104,15 +102,15 @@ class InterSatelliteLink {
104102
}
105103

106104
/**
107-
* @brief Calculate the directions for both satellites to face each other.
105+
* @brief Calculate the directions for both satellites to face each other. Because both satellites have to face each
106+
* other, the direction of satellite A is the negative direction of satellite B.
108107
* @param t [sec] time
109-
* @return Two direction vectors at the time when they face each other.
108+
* @return Direction vector for one of the satellites (origin) at the time when they face each other.
110109
*/
111-
EdgeOrientation getOrientation(const float time) const {
110+
glm::vec3 getOrientation(const float time) const {
112111
glm::vec3 sat1 = v1->cartesian_coordinates(time);
113112
glm::vec3 sat2 = v2->cartesian_coordinates(time);
114-
115-
return {glm::normalize(sat2 - sat1), glm::normalize(sat1 - sat2)};
113+
return glm::normalize(sat2 - sat1);
116114
}
117115

118116
// GETTER

src/opengl_widgets.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -699,12 +699,12 @@ void OpenGLWidget::prepareSolutionScene(const PhysicalInstance& instance, const
699699

700700
float t = scan.second; // time when edge is scheduled
701701
const InterSatelliteLink& isl = problem_instance.getISLs().at(scan.first);
702-
EdgeOrientation needed_orientation = isl.getOrientation(t);
702+
glm::vec3 needed_orientation = isl.getOrientation(t);
703703

704704
// add corresponding events for both satellites where they have to face in the needed
705705
// direction in order to perform the scan
706-
TimelineEvent<glm::vec3> orientation_sat1 = TimelineEvent<glm::vec3>(t, t, needed_orientation.first);
707-
TimelineEvent<glm::vec3> orientation_sat2 = TimelineEvent<glm::vec3>(t, t, needed_orientation.second);
706+
TimelineEvent<glm::vec3> orientation_sat1 = TimelineEvent<glm::vec3>(t, t, needed_orientation);
707+
TimelineEvent<glm::vec3> orientation_sat2 = TimelineEvent<glm::vec3>(t, t, -needed_orientation);
708708
bool res_1 = satellite_orientations[&isl.getV1()].insert(orientation_sat1);
709709
bool res_2 = satellite_orientations[&isl.getV2()].insert(orientation_sat2);
710710

src/solver/greedy_next.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ Solution GreedyNext::solve() {
4646

4747
// refresh orientation of chosen satellites.
4848
const InterSatelliteLink* e = remaining_edges.at(best_edge_pos);
49-
EdgeOrientation new_orientations = e->getOrientation(t_next);
50-
satellite_orientation[&e->getV1()] = TimelineEvent<glm::vec3>(t_next, t_next, new_orientations.first);
51-
satellite_orientation[&e->getV2()] = TimelineEvent<glm::vec3>(t_next, t_next, new_orientations.second);
49+
glm::vec3 new_orientations = e->getOrientation(t_next);
50+
satellite_orientation[&e->getV1()] = TimelineEvent<glm::vec3>(t_next, t_next, new_orientations);
51+
satellite_orientation[&e->getV2()] = TimelineEvent<glm::vec3>(t_next, t_next, -new_orientations);
5252

5353
// map position in remaining edges to position in all edges
5454
std::ptrdiff_t edge_index = remaining_edges[best_edge_pos] - &instance.getISLs()[0];

src/solver/greedy_next_khop.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ Solution GreedyNextKHop::solve() {
100100
}
101101

102102
// update satellite orientations
103-
EdgeOrientation new_orientations = isl->getOrientation(t_next);
104-
satellite_orientation[&isl->getV1()] = TimelineEvent<glm::vec3>(t_next, t_next, new_orientations.first);
105-
satellite_orientation[&isl->getV2()] = TimelineEvent<glm::vec3>(t_next, t_next, new_orientations.second);
103+
glm::vec3 new_orientations = isl->getOrientation(t_next);
104+
satellite_orientation[&isl->getV1()] = TimelineEvent<glm::vec3>(t_next, t_next, new_orientations);
105+
satellite_orientation[&isl->getV2()] = TimelineEvent<glm::vec3>(t_next, t_next, -new_orientations);
106106

107107
// update time
108108
curr_time = t_next;

0 commit comments

Comments
 (0)