-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #825 from hannobraun/fj
Make group and transform operations work on all shapes
- Loading branch information
Showing
10 changed files
with
147 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#[cfg(feature = "serde")] | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::Shape; | ||
|
||
/// A group of two 3-dimensional shapes | ||
/// | ||
/// A group is a collection of disjoint shapes. It is not a union, in that the | ||
/// shapes in the group are not allowed to touch or overlap. | ||
/// | ||
/// # Limitations | ||
/// | ||
/// Whether the shapes in the group touch or overlap is not currently checked. | ||
#[derive(Clone, Debug)] | ||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | ||
#[repr(C)] | ||
pub struct Group { | ||
/// The first of the shapes | ||
pub a: Shape, | ||
|
||
/// The second of the shapes | ||
pub b: Shape, | ||
} | ||
|
||
impl From<Group> for Shape { | ||
fn from(shape: Group) -> Self { | ||
Self::Group(Box::new(shape)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#[cfg(feature = "serde")] | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::{Shape, Shape2d}; | ||
|
||
/// A sweep of a 2-dimensional shape along straight path | ||
#[derive(Clone, Debug)] | ||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | ||
#[repr(C)] | ||
pub struct Sweep { | ||
/// The 2-dimensional shape being swept | ||
shape: Shape2d, | ||
|
||
/// The length and direction of the sweep | ||
path: [f64; 3], | ||
} | ||
|
||
impl Sweep { | ||
/// Create a `Sweep` along a straight path | ||
pub fn from_path(shape: Shape2d, path: [f64; 3]) -> Self { | ||
Self { shape, path } | ||
} | ||
|
||
/// Access the shape being swept | ||
pub fn shape(&self) -> &Shape2d { | ||
&self.shape | ||
} | ||
|
||
/// Access the path of the sweep | ||
pub fn path(&self) -> [f64; 3] { | ||
self.path | ||
} | ||
} | ||
|
||
impl From<Sweep> for Shape { | ||
fn from(shape: Sweep) -> Self { | ||
Self::Sweep(shape) | ||
} | ||
} |
Oops, something went wrong.