Skip to content

Commit

Permalink
Merge pull request #558 from hannobraun/line
Browse files Browse the repository at this point in the history
Replace `fj-kernel`'s `Line` with `fj_math::Line`
  • Loading branch information
hannobraun authored May 10, 2022
2 parents 72f601d + c287d2a commit f1bea10
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 152 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/fj-kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ categories = ["encoding", "mathematics", "rendering"]
[dependencies]
anyhow = "1.0.57"
anymap = "1.0.0-beta.2"
approx = "0.5.1"
map-macro = "0.2.0"
parking_lot = "0.12.0"
robust = "0.2.3"
Expand Down
4 changes: 2 additions & 2 deletions crates/fj-kernel/src/algorithms/intersection.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Intersection algorithms
use fj_math::{Point, Scalar, Vector};
use fj_math::{Line, Point, Scalar, Vector};

use crate::geometry::{Curve, Line, Surface};
use crate::geometry::{Curve, Surface};

/// Test intersection between two surfaces
pub fn surface(a: &Surface, b: &Surface) -> Option<Curve> {
Expand Down
133 changes: 0 additions & 133 deletions crates/fj-kernel/src/geometry/curves/line.rs

This file was deleted.

17 changes: 8 additions & 9 deletions crates/fj-kernel/src/geometry/curves/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
mod circle;
mod line;

pub use self::{circle::Circle, line::Line};
pub use self::circle::Circle;

use fj_math::{Point, Transform, Vector};
use fj_math::{Line, Point, Transform, Vector};

/// A one-dimensional shape
///
Expand All @@ -20,7 +19,7 @@ pub enum Curve {
Circle(Circle),

/// A line
Line(Line),
Line(Line<3>),
}

impl Curve {
Expand Down Expand Up @@ -52,7 +51,7 @@ impl Curve {
pub fn origin(&self) -> Point<3> {
match self {
Self::Circle(curve) => curve.origin(),
Self::Line(curve) => curve.origin(),
Self::Line(curve) => curve.origin,
}
}

Expand All @@ -70,7 +69,7 @@ impl Curve {
pub fn transform(self, transform: &Transform) -> Self {
match self {
Self::Circle(curve) => Self::Circle(curve.transform(transform)),
Self::Line(curve) => Self::Line(curve.transform(transform)),
Self::Line(curve) => Self::Line(transform.transform_line(&curve)),
}
}

Expand All @@ -86,23 +85,23 @@ impl Curve {
pub fn point_model_to_curve(&self, point: &Point<3>) -> Point<1> {
match self {
Self::Circle(curve) => curve.point_model_to_curve(point),
Self::Line(curve) => curve.point_model_to_curve(point),
Self::Line(curve) => curve.convert_point_to_line_coords(point),
}
}

/// Convert a point on the curve into model coordinates
pub fn point_curve_to_model(&self, point: &Point<1>) -> Point<3> {
match self {
Self::Circle(curve) => curve.point_curve_to_model(point),
Self::Line(curve) => curve.point_curve_to_model(point),
Self::Line(curve) => curve.convert_point_from_line_coords(point),
}
}

/// Convert a vector on the curve into model coordinates
pub fn vector_curve_to_model(&self, point: &Vector<1>) -> Vector<3> {
match self {
Self::Circle(curve) => curve.vector_curve_to_model(point),
Self::Line(curve) => curve.vector_curve_to_model(point),
Self::Line(curve) => curve.convert_vector_from_line_coords(point),
}
}
}
2 changes: 1 addition & 1 deletion crates/fj-kernel/src/geometry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod points;
mod surfaces;

pub use self::{
curves::{Circle, Curve, Line},
curves::{Circle, Curve},
points::Point,
surfaces::{Surface, SweptCurve},
};
6 changes: 3 additions & 3 deletions crates/fj-kernel/src/geometry/surfaces/swept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl SweptCurve {
/// Construct a plane from 3 points
#[cfg(test)]
pub fn plane_from_points([a, b, c]: [Point<3>; 3]) -> Self {
use crate::geometry::Line;
use fj_math::Line;

let curve = Curve::Line(Line::from_points([a, b]));
let path = c - a;
Expand Down Expand Up @@ -63,9 +63,9 @@ impl SweptCurve {
#[cfg(test)]
mod tests {

use fj_math::{Point, Vector};
use fj_math::{Line, Point, Vector};

use crate::geometry::{Curve, Line};
use crate::geometry::Curve;

use super::SweptCurve;

Expand Down
4 changes: 2 additions & 2 deletions crates/fj-kernel/src/topology/builder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use fj_math::{Point, Scalar, Vector};
use fj_math::{Line, Point, Scalar, Vector};

use crate::{
geometry::{Circle, Curve, Line, Surface},
geometry::{Circle, Curve, Surface},
shape::{Handle, Shape, ValidationResult},
};

Expand Down

0 comments on commit f1bea10

Please sign in to comment.