Skip to content

Commit

Permalink
Define circle radius using 2D vector
Browse files Browse the repository at this point in the history
The 3D definition is kind of wrong. I think all code currently assumes
that circles are in the x-y place[1]. Even if that weren't the case, a
single 3D vector would not be enough to define the plane of the circle.

I think the best solution for now is to make this change, and
investigate how the circle representation needs to be improved later.

[1] This would mean that circles and shapes based on circles can't
    currently be rotated. There's no issue to track this, so if this is
    true, one should be opened. I've added investigating this to my task
    list.
  • Loading branch information
hannobraun committed Feb 10, 2022
1 parent 02cad38 commit 622d58e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/kernel/geometry/curves/circle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ pub struct Circle {
/// The radius is represented by a vector that points from the center to the
/// circumference. The point on the circumference that it points to defines
/// the origin of the circle's 1-dimensional curve coordinate system.
pub radius: Vector<3>,
pub radius: Vector<2>,
}

impl Circle {
#[must_use]
pub fn transform(self, transform: &Isometry<f64>) -> Self {
let radius = vector![self.radius.x, self.radius.y, 0.];

Self {
center: transform.transform_point(&self.center),
radius: transform.transform_vector(&self.radius),
radius: transform.transform_vector(&radius).xy(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/kernel/topology/edges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl Edge {
Self {
curve: Curve::Circle(Circle {
center: Point::origin(),
radius: vector![radius, 0., 0.],
radius: vector![radius, 0.],
}),
vertices: None,
reverse: false,
Expand Down

0 comments on commit 622d58e

Please sign in to comment.