use start/end line angle of the turn rather than line from start point to end point.

update uses of turn.angle() now that it's relative
This commit is contained in:
Marcel Dejean 2021-10-27 15:12:47 -04:00 committed by Dustin Carlino
parent 3df3ee7aa5
commit 3bb3169ab4
4 changed files with 18 additions and 9 deletions

View File

@ -92,8 +92,8 @@ impl DrawBike {
draw_default.push(
cs.turn_arrow,
PolyLine::must_new(vec![
body_pos.project_away(body_radius / 2.0, angle.opposite()),
body_pos.project_away(body_radius / 2.0, angle),
body_pos.project_away(body_radius / 2.0, (facing + angle).opposite()),
body_pos.project_away(body_radius / 2.0, facing + angle),
])
.make_arrow(Distance::meters(0.15), ArrowCap::Triangle),
);

View File

@ -32,7 +32,7 @@ impl DrawPedestrian {
if let Some(t) = input.waiting_for_turn {
// A silly idea for peds... use hands to point at their turn?
let angle = map.get_t(t).angle();
let angle = input.facing + map.get_t(t).angle();
draw_default.push(
cs.turn_arrow,
PolyLine::must_new(vec![

View File

@ -199,7 +199,7 @@ impl DrawMovement {
}
// Produces (circle, arrow)
fn make_circle_geom(offset: f64, pl: PolyLine, angle: Angle) -> (Polygon, Polygon) {
fn make_circle_geom(offset: f64, pl: PolyLine, turn_angle: Angle) -> (Polygon, Polygon) {
let height = 2.0 * TURN_ICON_ARROW_LENGTH;
// Always extend the pl first to handle short entry lanes
let extension = PolyLine::must_new(vec![
@ -212,9 +212,10 @@ fn make_circle_geom(offset: f64, pl: PolyLine, angle: Angle) -> (Polygon, Polygo
let center = slice.middle();
let block = Circle::new(center, TURN_ICON_ARROW_LENGTH).to_polygon();
let arrow_angle = pl.last_line().angle().opposite() + turn_angle;
let arrow = PolyLine::must_new(vec![
center.project_away(TURN_ICON_ARROW_LENGTH / 2.0, angle.opposite()),
center.project_away(TURN_ICON_ARROW_LENGTH / 2.0, angle),
center.project_away(TURN_ICON_ARROW_LENGTH / 2.0, arrow_angle.opposite()),
center.project_away(TURN_ICON_ARROW_LENGTH / 2.0, arrow_angle),
])
.make_arrow(Distance::meters(0.5), ArrowCap::Triangle);

View File

@ -103,10 +103,18 @@ impl Turn {
self.geom.intersection(&other.geom).is_some()
}
// TODO What should this be for zero-length turns? Probably src's pt1 to dst's pt2 or
// something.
// The relative angle of the turn, should be the angle from the src lane to the dst lane, but
// instead uses the first and last lines of the turn geometry, which is currently not quite the
// same angle as between the source and destination lanes
pub fn angle(&self) -> Angle {
self.geom.first_pt().angle_to(self.geom.last_pt())
if self.geom.points().len() < 3 {
return Angle::ZERO;
}
self.geom
.last_line()
.angle()
.shortest_rotation_towards(self.geom.first_line().angle())
}
pub fn between_sidewalks(&self) -> bool {