use ::burn::tensor::{Tensor, backend::Backend};
pub type Coordinates<B> = (Tensor<B, 1>, Tensor<B, 1>);
pub type Point<B> = Tensor<B, 1>;
pub fn distance<B: Backend>(point: Point<B>, other: Point<B>) -> Tensor<B, 1> {
length(point - other)
}
pub fn left_normals<B: Backend>(
tangents: Coordinates<B>,
lengths: Tensor<B, 1>,
minimum_length: f32,
) -> Coordinates<B> {
let (x, y) = tangents;
let lengths = lengths.clamp_min(minimum_length);
(-y / lengths.clone(), x / lengths)
}
pub fn length<B: Backend>(point: Point<B>) -> Tensor<B, 1> {
point.powi_scalar(2).sum().sqrt()
}