|
|
|
@ -43,8 +43,10 @@ pub struct RouteCCC {
|
|
|
|
pub end: CircleVector,
|
|
|
|
pub end: CircleVector,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// right straight right route
|
|
|
|
/// Route with a start Circle, a tangent straight and a end Circle
|
|
|
|
pub fn rsr(end: Vector) -> Result<RouteCSC, ()> {
|
|
|
|
impl RouteCSC {
|
|
|
|
|
|
|
|
/// right straight right route
|
|
|
|
|
|
|
|
pub fn rsr(end: Vector) -> Result<Self, ()> {
|
|
|
|
let mut route_csc = RouteCSC {
|
|
|
|
let mut route_csc = RouteCSC {
|
|
|
|
start: CircleVector {
|
|
|
|
start: CircleVector {
|
|
|
|
center: Point::new(end.magnitude, 0.0),
|
|
|
|
center: Point::new(end.magnitude, 0.0),
|
|
|
|
@ -108,10 +110,10 @@ pub fn rsr(end: Vector) -> Result<RouteCSC, ()> {
|
|
|
|
route_csc.end.angle = (end.angle - route_csc.start.angle).positive();
|
|
|
|
route_csc.end.angle = (end.angle - route_csc.start.angle).positive();
|
|
|
|
|
|
|
|
|
|
|
|
Ok(route_csc)
|
|
|
|
Ok(route_csc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// left straight left route
|
|
|
|
/// left straight left route
|
|
|
|
pub fn lsl(end: Vector) -> Result<RouteCSC, ()> {
|
|
|
|
pub fn lsl(end: Vector) -> Result<Self, ()> {
|
|
|
|
let mut route_csc = RouteCSC {
|
|
|
|
let mut route_csc = RouteCSC {
|
|
|
|
start: CircleVector {
|
|
|
|
start: CircleVector {
|
|
|
|
center: Point::new(-end.magnitude, 0.0),
|
|
|
|
center: Point::new(-end.magnitude, 0.0),
|
|
|
|
@ -179,10 +181,10 @@ pub fn lsl(end: Vector) -> Result<RouteCSC, ()> {
|
|
|
|
route_csc.end.angle = (end.angle - route_csc.start.angle).positive();
|
|
|
|
route_csc.end.angle = (end.angle - route_csc.start.angle).positive();
|
|
|
|
|
|
|
|
|
|
|
|
Ok(route_csc)
|
|
|
|
Ok(route_csc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// right straight left route
|
|
|
|
/// right straight left route
|
|
|
|
pub fn rsl(end: Vector) -> Result<RouteCSC, ()> {
|
|
|
|
pub fn rsl(end: Vector) -> Result<Self, ()> {
|
|
|
|
let mut route_csc = RouteCSC {
|
|
|
|
let mut route_csc = RouteCSC {
|
|
|
|
start: CircleVector {
|
|
|
|
start: CircleVector {
|
|
|
|
center: Point::new(end.magnitude, 0.0),
|
|
|
|
center: Point::new(end.magnitude, 0.0),
|
|
|
|
@ -229,7 +231,8 @@ pub fn rsl(end: Vector) -> Result<RouteCSC, ()> {
|
|
|
|
|
|
|
|
|
|
|
|
// get the tangent angle
|
|
|
|
// get the tangent angle
|
|
|
|
route_csc.tangent.angle = Angle::radians(
|
|
|
|
route_csc.tangent.angle = Angle::radians(
|
|
|
|
((route_csc.end.center.y - tangent_middle.y) / (route_csc.end.center.x - tangent_middle.x))
|
|
|
|
((route_csc.end.center.y - tangent_middle.y)
|
|
|
|
|
|
|
|
/ (route_csc.end.center.x - tangent_middle.x))
|
|
|
|
.atan()
|
|
|
|
.atan()
|
|
|
|
- (2.0 * end.magnitude / route_csc.tangent.magnitude).atan(),
|
|
|
|
- (2.0 * end.magnitude / route_csc.tangent.magnitude).atan(),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
@ -251,13 +254,14 @@ pub fn rsl(end: Vector) -> Result<RouteCSC, ()> {
|
|
|
|
.transform_vector(Vector2D::new(route_csc.start.radius, 0.0));
|
|
|
|
.transform_vector(Vector2D::new(route_csc.start.radius, 0.0));
|
|
|
|
|
|
|
|
|
|
|
|
// get the angle of the end circle
|
|
|
|
// get the angle of the end circle
|
|
|
|
route_csc.end.angle = ((Angle::frac_pi_2() - end.angle) - route_csc.tangent.angle).positive();
|
|
|
|
route_csc.end.angle =
|
|
|
|
|
|
|
|
((Angle::frac_pi_2() - end.angle) - route_csc.tangent.angle).positive();
|
|
|
|
|
|
|
|
|
|
|
|
Ok(route_csc)
|
|
|
|
Ok(route_csc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// left straight right route
|
|
|
|
/// left straight right route
|
|
|
|
pub fn lsr(end: Vector) -> Result<RouteCSC, ()> {
|
|
|
|
pub fn lsr(end: Vector) -> Result<Self, ()> {
|
|
|
|
let mut route_csc = RouteCSC {
|
|
|
|
let mut route_csc = RouteCSC {
|
|
|
|
start: CircleVector {
|
|
|
|
start: CircleVector {
|
|
|
|
center: Point::new(-end.magnitude, 0.0),
|
|
|
|
center: Point::new(-end.magnitude, 0.0),
|
|
|
|
@ -305,7 +309,8 @@ pub fn lsr(end: Vector) -> Result<RouteCSC, ()> {
|
|
|
|
|
|
|
|
|
|
|
|
// get the tangent angle
|
|
|
|
// get the tangent angle
|
|
|
|
route_csc.tangent.angle = Angle::radians(
|
|
|
|
route_csc.tangent.angle = Angle::radians(
|
|
|
|
((route_csc.end.center.y - tangent_middle.y) / (route_csc.end.center.x - tangent_middle.x))
|
|
|
|
((route_csc.end.center.y - tangent_middle.y)
|
|
|
|
|
|
|
|
/ (route_csc.end.center.x - tangent_middle.x))
|
|
|
|
.atan()
|
|
|
|
.atan()
|
|
|
|
+ (2.0 * end.magnitude / route_csc.tangent.magnitude).atan(),
|
|
|
|
+ (2.0 * end.magnitude / route_csc.tangent.magnitude).atan(),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
@ -320,6 +325,23 @@ pub fn lsr(end: Vector) -> Result<RouteCSC, ()> {
|
|
|
|
// get the angle of the start circle
|
|
|
|
// get the angle of the start circle
|
|
|
|
route_csc.start.angle = (route_csc.tangent.angle - Angle::frac_pi_2()).positive();
|
|
|
|
route_csc.start.angle = (route_csc.tangent.angle - Angle::frac_pi_2()).positive();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get the tangent origin by moving the vector from the start circle center
|
|
|
|
|
|
|
|
// 90° to it's own direction and the magnitude of the circle radius
|
|
|
|
|
|
|
|
route_csc.tangent.origin = route_csc.start.center
|
|
|
|
|
|
|
|
+ Rotation::new(route_csc.start.angle)
|
|
|
|
|
|
|
|
.transform_vector(Vector2D::new(route_csc.start.radius, 0.0));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get the angle of the end circle
|
|
|
|
|
|
|
|
route_csc.end.angle =
|
|
|
|
|
|
|
|
((Angle::frac_pi_2() - end.angle) - route_csc.tangent.angle).positive();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ok(route_csc)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get the angle of the start circle
|
|
|
|
|
|
|
|
route_csc.start.angle = (route_csc.tangent.angle - Angle::frac_pi_2()).positive();
|
|
|
|
|
|
|
|
|
|
|
|
// get the tangent origin by moving the vector from the start circle center
|
|
|
|
// get the tangent origin by moving the vector from the start circle center
|
|
|
|
// 90° to it's own direction and the magnitude of the circle radius
|
|
|
|
// 90° to it's own direction and the magnitude of the circle radius
|
|
|
|
route_csc.tangent.origin = route_csc.start.center
|
|
|
|
route_csc.tangent.origin = route_csc.start.center
|
|
|
|
|