Add LineSegment::to_line

This commit is contained in:
Hanno Braun 2024-09-26 19:49:01 +02:00
parent b88f4728dc
commit ef5830fc79

View File

@ -1,6 +1,6 @@
use std::fmt; use std::fmt;
use crate::Scalar; use crate::{Line, Scalar};
use super::Point; use super::Point;
@ -30,6 +30,16 @@ impl<const D: usize> LineSegment<D> {
self.points.reverse(); self.points.reverse();
self self
} }
/// # Convert this `LineSegment` into a [`Line`]
///
/// This provides access to various utility methods.
pub fn to_line(&self) -> Line<D> {
let [a, b] = self.points;
let [a_line, b_line] = self.points_line;
Line::from_points_with_line_coords([(a_line, a), (b_line, b)])
}
} }
impl LineSegment<2> { impl LineSegment<2> {