Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Cherry might be for you if:

### Now
- [ ] Systems with beam splitters
- [ ] Paraxial surface types
- [X] Thin lens surface types
- [ ] Surface coatings
- [ ] Encode designs into URLs and enable sharing via tiny URLs

Expand Down
5 changes: 5 additions & 0 deletions crates/cherry-rs/src/core/math/vec3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ impl Vec3 {
vecs
}

/// Returns `true` if all three components are finite (not infinite or NaN).
pub fn is_finite(&self) -> bool {
self.e[0].is_finite() && self.e[1].is_finite() && self.e[2].is_finite()
}

pub fn approx_eq(&self, rhs: &Self, tol: Float) -> bool {
(self.e[0] - rhs.e[0]).abs() < tol
&& (self.e[1] - rhs.e[1]).abs() < tol
Expand Down
8 changes: 5 additions & 3 deletions crates/cherry-rs/src/core/ray.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#[cfg(feature = "serde")]
use serde::Serialize;

use crate::core::{Float, PI, math::vec3::Vec3, sequential_model::placement::Placement};
use crate::core::{
Float, PI, math::vec3::Vec3, sequential_model::surface_placement::SurfacePlacement,
};

/// A single ray to be traced through an optical system.
///
Expand Down Expand Up @@ -45,14 +47,14 @@ impl Ray {

/// Transform a ray into the local coordinate system of a surface from the
/// global system.
pub fn transform(&mut self, placement: &Placement) {
pub fn transform(&mut self, placement: &SurfacePlacement) {
self.pos = placement.rotation_matrix * (self.pos - placement.position);
self.dir = placement.rotation_matrix * self.dir;
}

/// Transform a ray from the local coordinate system of a surface into the
/// global system.
pub fn i_transform(&mut self, placement: &Placement) {
pub fn i_transform(&mut self, placement: &SurfacePlacement) {
self.pos = (placement.inv_rotation_matrix * self.pos) + placement.position;
self.dir = placement.inv_rotation_matrix * self.dir;
}
Expand Down
Loading
Loading