chore: fix deprecation warnings about geo::EuclideanDistance

This commit is contained in:
Alain Emilia Anna Zscheile 2024-12-11 19:48:16 +01:00 committed by mikolaj
parent 35b2958c8d
commit 8a724dc5d2
5 changed files with 22 additions and 17 deletions

View File

@ -1,4 +1,5 @@
use geo::{Centroid, Contains, EuclideanLength, Point, Polygon};
use geo::algorithm::line_measures::{Euclidean, Length};
use geo::{Centroid, Contains, Point, Polygon};
use crate::geometry::shape::{AccessShape, MeasureLength};
@ -12,7 +13,7 @@ impl MeasureLength for PolyShape {
let mut length = 0.0;
for line in self.polygon.exterior().lines() {
length += line.euclidean_length();
length += line.length::<Euclidean>();
}
length

View File

@ -1,7 +1,8 @@
use std::f64::consts::TAU;
use enum_dispatch::enum_dispatch;
use geo::{point, polygon, Contains, EuclideanDistance, Intersects, Point, Polygon, Rotate};
use geo::algorithm::line_measures::{Distance, Euclidean};
use geo::{point, polygon, Contains, Intersects, Point, Polygon, Rotate};
use rstar::{RTreeObject, AABB};
use crate::{
@ -64,7 +65,7 @@ impl AccessShape for DotShape {
}
fn contains_point(&self, p: Point) -> bool {
p.euclidean_distance(&self.circle.pos) <= self.circle.r
Euclidean::distance(&p, &self.circle.pos) <= self.circle.r
}
}
@ -89,11 +90,11 @@ impl AccessPrimitiveShape for DotShape {
match other {
PrimitiveShape::Dot(other) => {
self.circle.pos.euclidean_distance(&other.circle.pos)
Euclidean::distance(&self.circle.pos, &other.circle.pos)
< self.circle.r + other.circle.r
}
PrimitiveShape::Seg(other) => {
self.circle.pos.euclidean_distance(&other.polygon()) < self.circle.r
Euclidean::distance(&self.circle.pos, &other.polygon()) < self.circle.r
}
PrimitiveShape::Bend(other) => {
for point in math::intersect_circles(&self.circle, &other.inner_circle()) {
@ -141,7 +142,7 @@ pub struct SegShape {
impl SegShape {
fn polygon(&self) -> Polygon {
let tangent_vector = self.to - self.from;
let tangent_vector_norm = tangent_vector.euclidean_distance(&point! {x: 0.0, y: 0.0});
let tangent_vector_norm = Euclidean::distance(&tangent_vector, &point! {x: 0.0, y: 0.0});
let unit_tangent_vector = tangent_vector / tangent_vector_norm;
let normal = unit_tangent_vector.rotate_around_point(-90., point! {x: 0.0, y: 0.0});
@ -157,7 +158,7 @@ impl SegShape {
impl MeasureLength for SegShape {
fn length(&self) -> f64 {
self.to.euclidean_distance(&self.from)
Euclidean::distance(&self.to, &self.from)
}
}
@ -318,11 +319,12 @@ impl AccessShape for BendShape {
fn center(&self) -> Point {
let sum = (self.from - self.inner_circle.pos) + (self.to - self.inner_circle.pos);
self.inner_circle.pos
+ (sum / sum.euclidean_distance(&point! {x: 0.0, y: 0.0})) * self.inner_circle.r
+ (sum / Euclidean::distance(&sum, &geo::point! { x: 0.0, y: 0.0 }))
* self.inner_circle.r
}
fn contains_point(&self, p: Point) -> bool {
let d = p.euclidean_distance(&self.inner_circle.pos);
let d = Euclidean::distance(&p, &self.inner_circle.pos);
self.between_ends(p) && d >= self.inner_circle().r && d <= self.outer_circle().r
}
}

View File

@ -1,4 +1,5 @@
use geo::{geometry::Point, point, EuclideanDistance, Line};
use geo::algorithm::line_measures::{Distance, Euclidean};
use geo::{geometry::Point, point, Line};
use thiserror::Error;
#[derive(Error, Debug, Clone, Copy, PartialEq)]
@ -128,7 +129,7 @@ pub fn tangent_segment(
pub fn intersect_circles(circle1: &Circle, circle2: &Circle) -> Vec<Point> {
let delta = circle2.pos - circle1.pos;
let d = circle2.pos.euclidean_distance(&circle1.pos);
let d = Euclidean::distance(&circle2.pos, &circle1.pos);
if d > circle1.r + circle2.r {
// No intersection.

View File

@ -1,5 +1,5 @@
use derive_getters::Getters;
use geo::EuclideanDistance;
use geo::algorithm::line_measures::{Distance, Euclidean};
use petgraph::{data::DataMap, visit::EdgeRef};
use serde::{Deserialize, Serialize};
@ -164,7 +164,7 @@ impl<'a, R: AccessRules> AstarStrategy<Navmesh, f64, BandTermsegIndex>
.shape()
.center();
end_point.euclidean_distance(&start_point)
Euclidean::distance(&end_point, &start_point)
}
}

View File

@ -1,6 +1,7 @@
use std::{cmp::Ordering, marker::PhantomData};
use geo::{point, EuclideanDistance, Point};
use geo::algorithm::line_measures::{Distance, Euclidean};
use geo::{point, Point};
use petgraph::visit;
use spade::{handles::FixedVertexHandle, DelaunayTriangulation, HasPosition, InsertionError};
@ -178,7 +179,7 @@ impl<
from,
to,
weight: TriangulationEdgeWeightWrapper {
length: self.position(from).euclidean_distance(&self.position(to)),
length: Euclidean::distance(&self.position(from), &self.position(to)),
weight: *edge.data(),
},
}
@ -208,7 +209,7 @@ impl<
from,
to,
weight: TriangulationEdgeWeightWrapper {
length: self.position(from).euclidean_distance(&self.position(to)),
length: Euclidean::distance(&self.position(from), &self.position(to)),
weight: *edge.data(),
},
}