Add geometry::Circle

This commit is contained in:
Hanno Braun 2025-04-28 13:13:43 +02:00
parent 0fbc0bf12d
commit a5326b00b4
3 changed files with 29 additions and 5 deletions

View File

@ -0,0 +1,18 @@
use fj_math::{Point, Vector};
pub struct Circle {
pub a: Vector<3>,
pub b: Vector<3>,
}
impl Circle {
pub fn vector_from_local_point(
&self,
point: impl Into<Point<1>>,
) -> Vector<3> {
let angle = point.into().t;
let (sin, cos) = angle.sin_cos();
self.a * cos + self.b * sin - self.a
}
}

View File

@ -1,7 +1,7 @@
use fj_interop::{CircleApproxParams, Tolerance}; use fj_interop::{CircleApproxParams, Tolerance};
use fj_math::{Point, Transform, Vector}; use fj_math::{Point, Transform, Vector};
use super::Line; use super::{Circle, Line};
/// # Curve geometry that has a fixed position (is _anchored_) in space /// # Curve geometry that has a fixed position (is _anchored_) in space
/// ///
@ -104,9 +104,14 @@ impl CurveGeometry for (Point<3>, fj_math::Circle<3>) {
} }
fn point_from_local(&self, point: Point<1>) -> Point<3> { fn point_from_local(&self, point: Point<1>) -> Point<3> {
let (_, circle) = *self; let (offset, circle) = *self;
circle.point_from_circle_coords(point) let circle = Circle {
a: circle.a(),
b: circle.b(),
};
offset + circle.vector_from_local_point(point)
} }
fn project_point(&self, point: Point<3>) -> Point<1> { fn project_point(&self, point: Point<3>) -> Point<1> {

View File

@ -1,3 +1,4 @@
mod circle;
mod curve; mod curve;
mod line; mod line;
mod sketch; mod sketch;
@ -6,6 +7,6 @@ mod swept_curve;
mod tri_mesh; mod tri_mesh;
pub use self::{ pub use self::{
curve::AnchoredCurve, line::Line, sketch::Sketch, surface::SurfaceGeometry, circle::Circle, curve::AnchoredCurve, line::Line, sketch::Sketch,
swept_curve::SweptCurve, tri_mesh::ToTriMesh, surface::SurfaceGeometry, swept_curve::SweptCurve, tri_mesh::ToTriMesh,
}; };