mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-04 18:08:26 +00:00
Add geometry::Circle
This commit is contained in:
parent
0fbc0bf12d
commit
a5326b00b4
18
experiments/2025-03-18/src/geometry/circle.rs
Normal file
18
experiments/2025-03-18/src/geometry/circle.rs
Normal 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
|
||||||
|
}
|
||||||
|
}
|
@ -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> {
|
||||||
|
@ -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,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user