VCM: line intersection
This commit is contained in:
parent
549af5630b
commit
e92fba0a32
35
src/vcm.c
35
src/vcm.c
|
|
@ -20,33 +20,28 @@ static int are_vehicles_intersecting(
|
||||||
// TODO check first time intersection, then the spacial trajectory
|
// TODO check first time intersection, then the spacial trajectory
|
||||||
double A1[2], A2[2], B1[2], B2[2];
|
double A1[2], A2[2], B1[2], B2[2];
|
||||||
uint64_t tsA, tsB;
|
uint64_t tsA, tsB;
|
||||||
for (int a = 0; a < tA_len; ++a) {
|
for (int a = 0; a < tA_len-1; ++a) {
|
||||||
// for (int a = 0; a < tA_len-1; ++a) {
|
A1[0] = tA[a].latitude;
|
||||||
// A1[0] = tA[a].latitude;
|
A1[1] = tA[a].longitude;
|
||||||
// A1[1] = tA[a].longitude;
|
A2[0] = tA[a+1].latitude;
|
||||||
// A2[0] = tA[a+1].latitude;
|
A2[1] = tA[a+1].longitude;
|
||||||
// A2[1] = tA[a+1].longitude;
|
for (int b = 0; b < tB_len-1; ++b) {
|
||||||
|
if (tA[a].timestamp > tB[b].timestamp + 1000 ||
|
||||||
|
tA[a].timestamp < tB[b].timestamp - 1000) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
B1[0] = tB[b].latitude;
|
||||||
|
B1[1] = tB[b].longitude;
|
||||||
|
B2[0] = tB[b+1].latitude;
|
||||||
|
B2[1] = tB[b+1].longitude;
|
||||||
|
|
||||||
for (int b = 0; b < tB_len; ++b) {
|
if (itss_do_segments_intersect(A1, A2, B1, B2)) {
|
||||||
// for (int b = 0; b < tB_len-1; ++b) {
|
|
||||||
// B1[0] = tB[b].latitude;
|
|
||||||
// B1[1] = tB[b].longitude;
|
|
||||||
// B2[0] = tB[b+1].latitude;
|
|
||||||
// B2[1] = tB[b+1].longitude;
|
|
||||||
|
|
||||||
// if (itss_do_segments_intersect(A1, A2, B1, B2)) {
|
|
||||||
// printf("tA[a].lat=%d tA[a].lon=%d tB[b].lat=%d tB[b].lon=%d tA[a].ts=%ld tB[b].ts=%ld\n",
|
|
||||||
// tA[a].latitude, tA[a].longitude, tB[b].latitude, tB[b].longitude, tA[a].timestamp, tB[b].timestamp); fflush(stdout);
|
|
||||||
if (itss_is_inside_circle(tA[a].latitude, tA[a].longitude, tB[b].latitude, tB[b].longitude, 8, DCM_HAVERSINE)) {
|
|
||||||
if (tA[a].timestamp < tB[b].timestamp + 2000 &&
|
|
||||||
tA[a].timestamp > tB[b].timestamp - 2000) {
|
|
||||||
*index = a;
|
*index = a;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue