diff --git a/.gitignore b/.gitignore index acfbb12..f9a7ded 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ Pathfinder-Java/.gradle/ Pathfinder-Core/build/ test/build .gradle/ +**/gradle.properties out/ .idea diff --git a/Pathfinder-Core/src/modifiers/tank.c b/Pathfinder-Core/src/modifiers/tank.c index a51fbbb..0045de6 100644 --- a/Pathfinder-Core/src/modifiers/tank.c +++ b/Pathfinder-Core/src/modifiers/tank.c @@ -14,34 +14,42 @@ void pathfinder_modify_tank(Segment *original, int length, Segment *left_traj, S left.x = seg.x - (w * sin_angle); left.y = seg.y + (w * cos_angle); - - if (i > 0) { - Segment last = left_traj[i - 1]; - double distance = sqrt( - (left.x - last.x) * (left.x - last.x) - + (left.y - last.y) * (left.y - last.y) - ); - - left.position = last.position + distance; - left.velocity = distance / seg.dt; - left.acceleration = (left.velocity - last.velocity) / seg.dt; - left.jerk = (left.acceleration - last.acceleration) / seg.dt; - } - + right.x = seg.x + (w * sin_angle); right.y = seg.y - (w * cos_angle); - + if (i > 0) { - Segment last = right_traj[i - 1]; - double distance = sqrt( - (right.x - last.x) * (right.x - last.x) - + (right.y - last.y) * (right.y - last.y) + Segment last_seg = original[i - 1]; + Segment last_left = left_traj[i - 1]; + Segment last_right = right_traj[i - 1]; + + double left_distance = sqrt( + (left.x - last_left.x) * (left.x - last_left.x) + + (left.y - last_left.y) * (left.y - last_left.y) + ); + if ((last_seg.x > seg.x && last_left.x < left.x) || (last_seg.y > seg.y && last_left.y < left.y) || + (last_seg.x < seg.x && last_left.x > left.x) || (last_seg.y < seg.y && last_left.y > left.y)) { + left_distance = -left_distance; + } + + double right_distance = sqrt( + (right.x - last_right.x) * (right.x - last_right.x) + + (right.y - last_right.y) * (right.y - last_right.y) ); - - right.position = last.position + distance; - right.velocity = distance / seg.dt; - right.acceleration = (right.velocity - last.velocity) / seg.dt; - right.jerk = (right.acceleration - last.acceleration) / seg.dt; + if ((last_seg.x > seg.x && last_right.x < right.x) || (last_seg.y > seg.y && last_right.y < right.y) || + (last_seg.x < seg.x && last_right.x > right.x) || (last_seg.y < seg.y && last_right.y > right.y)) { + right_distance = -right_distance; + } + + left.position = last_left.position + left_distance; + left.velocity = left_distance / seg.dt; + left.acceleration = (left.velocity - last_left.velocity) / seg.dt; + left.jerk = (left.acceleration - last_left.acceleration) / seg.dt; + + right.position = last_right.position + right_distance; + right.velocity = right_distance / seg.dt; + right.acceleration = (right.velocity - last_right.velocity) / seg.dt; + right.jerk = (right.acceleration - last_right.acceleration) / seg.dt; } left_traj[i] = left; diff --git a/build.gradle b/build.gradle index f0f122d..b365acc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { - id "jaci.openrio.gradle.GradleRIO" version "2018.01.07" apply false - id "jaci.gradle.EmbeddedTools" version "2018.01.06b" apply false + id "jaci.openrio.gradle.GradleRIO" version "2018.02.17" apply false + id "jaci.gradle.EmbeddedTools" version "2018.02.04" apply false } allprojects { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 225bf9a..85bcf49 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Jan 08 18:23:30 AWST 2018 +#Fri Feb 16 20:00:20 EST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip