Trait vox_geometry_rust::surface3::Surface3 [−][src]
pub trait Surface3 {}Show methods
fn closest_point_local(&self, other_point: &Vector3D) -> Vector3D; fn bounding_box_local(&self) -> BoundingBox3D; fn closest_intersection_local(&self, ray: &Ray3D) -> SurfaceRayIntersection3; fn closest_normal_local(&self, other_point: &Vector3D) -> Vector3D; fn view(&self) -> &Surface3Data; fn intersects_local(&self, ray_local: &Ray3D) -> bool { ... } fn closest_distance_local(&self, other_point_local: &Vector3D) -> f64 { ... } fn is_inside_local(&self, other_point_local: &Vector3D) -> bool { ... } fn closest_point(&self, other_point: &Vector3D) -> Vector3D { ... } fn bounding_box(&self) -> BoundingBox3D { ... } fn intersects(&self, ray: &Ray3D) -> bool { ... } fn closest_distance(&self, other_point: &Vector3D) -> f64 { ... } fn closest_intersection(&self, ray: &Ray3D) -> SurfaceRayIntersection3 { ... } fn closest_normal(&self, other_point: &Vector3D) -> Vector3D { ... } fn update_query_engine(&self) { ... } fn is_bounded(&self) -> bool { ... } fn is_valid_geometry(&self) -> bool { ... } fn is_inside(&self, other_point: &Vector3D) -> bool { ... }
Expand description
Abstract base class for 3-D surface.
Required methods
fn closest_point_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn closest_point_local(&self, other_point: &Vector3D) -> Vector3D
[src]Returns the closest point from the given point \p other_point to the surface in local frame.
fn bounding_box_local(&self) -> BoundingBox3D
[src]
fn bounding_box_local(&self) -> BoundingBox3D
[src]Returns the bounding box of this surface object in local frame.
fn closest_intersection_local(&self, ray: &Ray3D) -> SurfaceRayIntersection3
[src]
fn closest_intersection_local(&self, ray: &Ray3D) -> SurfaceRayIntersection3
[src]Returns the closest intersection point for given \p ray in local frame.
fn closest_normal_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn closest_normal_local(&self, other_point: &Vector3D) -> Vector3D
[src]Returns the normal to the closest point on the surface from the given point \p other_point in local frame.
fn view(&self) -> &Surface3Data
[src]
fn view(&self) -> &Surface3Data
[src]Provided methods
fn intersects_local(&self, ray_local: &Ray3D) -> bool
[src]
fn intersects_local(&self, ray_local: &Ray3D) -> bool
[src]Returns true if the given \p ray intersects with this surface object in local frame.
fn closest_distance_local(&self, other_point_local: &Vector3D) -> f64
[src]
fn closest_distance_local(&self, other_point_local: &Vector3D) -> f64
[src]Returns the closest distance from the given point \p otherPoint to the point on the surface in local frame.
fn is_inside_local(&self, other_point_local: &Vector3D) -> bool
[src]
fn is_inside_local(&self, other_point_local: &Vector3D) -> bool
[src]Returns true if \p otherPoint is inside by given \p depth the volume defined by the surface in local frame.
fn closest_point(&self, other_point: &Vector3D) -> Vector3D
[src]
fn closest_point(&self, other_point: &Vector3D) -> Vector3D
[src]Returns the closest point from the given point \p other_point to the surface.
fn bounding_box(&self) -> BoundingBox3D
[src]
fn bounding_box(&self) -> BoundingBox3D
[src]Returns the bounding box of this surface object.
fn intersects(&self, ray: &Ray3D) -> bool
[src]
fn intersects(&self, ray: &Ray3D) -> bool
[src]Returns true if the given \p ray intersects with this surface object.
fn closest_distance(&self, other_point: &Vector3D) -> f64
[src]
fn closest_distance(&self, other_point: &Vector3D) -> f64
[src]Returns the closest distance from the given point \p other_point to the point on the surface.
fn closest_intersection(&self, ray: &Ray3D) -> SurfaceRayIntersection3
[src]
fn closest_intersection(&self, ray: &Ray3D) -> SurfaceRayIntersection3
[src]Returns the closest intersection point for given \p ray.
fn closest_normal(&self, other_point: &Vector3D) -> Vector3D
[src]
fn closest_normal(&self, other_point: &Vector3D) -> Vector3D
[src]Returns the normal to the closest point on the surface from the given point \p other_point.
fn update_query_engine(&self)
[src]
fn update_query_engine(&self)
[src]Updates internal spatial query engine.
fn is_bounded(&self) -> bool
[src]
fn is_bounded(&self) -> bool
[src]Returns true if bounding box can be defined.
Implementors
impl Surface3 for Box3
[src]
impl Surface3 for Box3
[src]fn closest_point_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn bounding_box_local(&self) -> BoundingBox3D
[src]
fn closest_intersection_local(&self, ray: &Ray3D) -> SurfaceRayIntersection3
[src]
fn closest_normal_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn intersects_local(&self, ray_local: &Ray3D) -> bool
[src]
fn view(&self) -> &Surface3Data
[src]
impl Surface3 for CustomImplicitSurface3
[src]
impl Surface3 for CustomImplicitSurface3
[src]fn closest_point_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn bounding_box_local(&self) -> BoundingBox3D
[src]
fn closest_intersection_local(&self, ray: &Ray3D) -> SurfaceRayIntersection3
[src]
fn closest_normal_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn intersects_local(&self, ray: &Ray3D) -> bool
[src]
fn view(&self) -> &Surface3Data
[src]
impl Surface3 for Cylinder3
[src]
impl Surface3 for Cylinder3
[src]fn closest_point_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn bounding_box_local(&self) -> BoundingBox3D
[src]
fn closest_intersection_local(&self, ray: &Ray3D) -> SurfaceRayIntersection3
[src]
fn closest_normal_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn intersects_local(&self, ray: &Ray3D) -> bool
[src]
fn closest_distance_local(&self, other_point_local: &Vector3D) -> f64
[src]
fn view(&self) -> &Surface3Data
[src]
impl Surface3 for ImplicitSurfaceSet3
[src]
impl Surface3 for ImplicitSurfaceSet3
[src]fn closest_point_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn bounding_box_local(&self) -> BoundingBox3D
[src]
fn closest_intersection_local(&self, ray: &Ray3D) -> SurfaceRayIntersection3
[src]
fn closest_normal_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn intersects_local(&self, ray: &Ray3D) -> bool
[src]
fn closest_distance_local(&self, other_point: &Vector3D) -> f64
[src]
fn update_query_engine(&self)
[src]
fn is_bounded(&self) -> bool
[src]
fn is_valid_geometry(&self) -> bool
[src]
fn view(&self) -> &Surface3Data
[src]
impl Surface3 for Plane3
[src]
impl Surface3 for Plane3
[src]fn closest_point_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn bounding_box_local(&self) -> BoundingBox3D
[src]
fn closest_intersection_local(&self, ray: &Ray3D) -> SurfaceRayIntersection3
[src]
fn closest_normal_local(&self, _other_point: &Vector3D) -> Vector3D
[src]
fn intersects_local(&self, ray_local: &Ray3D) -> bool
[src]
fn view(&self) -> &Surface3Data
[src]
impl Surface3 for Sphere3
[src]
impl Surface3 for Sphere3
[src]fn closest_point_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn bounding_box_local(&self) -> BoundingBox3D
[src]
fn closest_intersection_local(&self, ray: &Ray3D) -> SurfaceRayIntersection3
[src]
fn closest_normal_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn intersects_local(&self, ray_local: &Ray3D) -> bool
[src]
fn closest_distance_local(&self, other_point_local: &Vector3D) -> f64
[src]
fn view(&self) -> &Surface3Data
[src]
impl Surface3 for SurfaceSet3
[src]
impl Surface3 for SurfaceSet3
[src]fn closest_point_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn closest_point_local(&self, other_point: &Vector3D) -> Vector3D
[src]use vox_geometry_rust::surface3::*; use vox_geometry_rust::surface_set3::SurfaceSet3; use vox_geometry_rust::sphere3::*; use vox_geometry_rust::vector3::Vector3D; use vox_geometry_rust::unit_tests_utils::*; let mut sset1 = SurfaceSet3::new_default(); // Test empty set let empty_point = sset1.closest_point(&Vector3D::new(1.0, 2.0, 3.0)); assert_eq!(f64::MAX, empty_point.x); assert_eq!(f64::MAX, empty_point.y); assert_eq!(f64::MAX, empty_point.z); let num_samples = get_number_of_sample_points3(); // Use first half of the samples as the centers of the spheres for i in 0..num_samples/2 { let sph = Sphere3::builder() .with_radius(0.01) .with_center(Vector3D::new_lst(get_sample_points3()[i])) .make_shared(); sset1.add_surface(sph); } let brute_force_search = |pt:&Vector3D| { let mut min_dist3 = f64::MAX; let mut result = Vector3D::new_default(); for i in 0..num_samples/2 { let local_result = sset1.surface_at(i).read().unwrap().closest_point(pt); let local_dist3 = pt.distance_squared_to(local_result); if local_dist3 < min_dist3 { min_dist3 = local_dist3; result = local_result; } } return result; }; // Use second half of the samples as the query points for i in num_samples/2..num_samples { let actual = sset1.closest_point(&Vector3D::new_lst(get_sample_points3()[i])); let expected = brute_force_search(&Vector3D::new_lst(get_sample_points3()[i])); assert_eq!(expected, actual); } // Now with translation instead of center let mut sset3 = SurfaceSet3::new_default(); for i in 0..num_samples/2 { let sph = Sphere3::builder() .with_radius(0.01) .with_center(Vector3D::new_default()) .with_translation(Vector3D::new_lst(get_sample_points3()[i])) .make_shared(); sset3.add_surface(sph); } for i in num_samples/2..num_samples { let actual = sset3.closest_point(&Vector3D::new_lst(get_sample_points3()[i])); let expected = brute_force_search(&Vector3D::new_lst(get_sample_points3()[i])); assert_eq!(expected, actual); }
fn bounding_box_local(&self) -> BoundingBox3D
[src]
fn bounding_box_local(&self) -> BoundingBox3D
[src]use vox_geometry_rust::surface3::*; use vox_geometry_rust::surface_set3::SurfaceSet3; use vox_geometry_rust::sphere3::*; use vox_geometry_rust::vector3::{Vector3D, Vector3}; use vox_geometry_rust::bounding_box3::BoundingBox3D; use vox_geometry_rust::unit_tests_utils::*; let mut sset1 = SurfaceSet3::new_default(); let num_samples = get_number_of_sample_points3(); // Use first half of the samples as the centers of the spheres let mut answer = BoundingBox3D::new_default(); for i in 0..num_samples/2 { let sph = Sphere3::builder() .with_radius(0.01) .with_center(Vector3D::new_lst(get_sample_points3()[i])) .make_shared(); sset1.add_surface(sph.clone()); answer.merge_box(&sph.read().unwrap().bounding_box()); } assert_eq!(answer.lower_corner.is_similar(&sset1.bounding_box().lower_corner, Some(1e-9)), true); assert_eq!(answer.upper_corner.is_similar(&sset1.bounding_box().upper_corner, Some(1e-9)), true); // Now with translation instead of center let mut sset3 = SurfaceSet3::new_default(); let mut debug = BoundingBox3D::new_default(); for i in 0..num_samples/2 { let sph = Sphere3::builder() .with_radius(0.01) .with_center(Vector3D::new_default()) .with_translation(Vector3D::new_lst(get_sample_points3()[i])) .make_shared(); sset3.add_surface(sph.clone()); debug.merge_box(&sph.read().unwrap().bounding_box()); } assert_eq!(answer.lower_corner.is_similar(&debug.lower_corner, Some(1e-9)), true); assert_eq!(answer.upper_corner.is_similar(&debug.upper_corner, Some(1e-9)), true); assert_eq!(answer.lower_corner.is_similar(&sset3.bounding_box().lower_corner, Some(1e-9)), true); assert_eq!(answer.upper_corner.is_similar(&sset3.bounding_box().upper_corner, Some(1e-9)), true);
fn closest_intersection_local(&self, ray: &Ray3D) -> SurfaceRayIntersection3
[src]
fn closest_intersection_local(&self, ray: &Ray3D) -> SurfaceRayIntersection3
[src]use vox_geometry_rust::surface3::*; use vox_geometry_rust::surface_set3::SurfaceSet3; use vox_geometry_rust::sphere3::*; use vox_geometry_rust::vector3::{Vector3D, Vector3}; use vox_geometry_rust::ray3::Ray3D; use vox_geometry_rust::unit_tests_utils::*; let mut sset1 = SurfaceSet3::new_default(); let num_samples = get_number_of_sample_points3(); // Use first half of the samples as the centers of the spheres for i in 0..num_samples/2 { let sph = Sphere3::builder() .with_radius(0.01) .with_center(Vector3D::new_lst(get_sample_points3()[i])) .make_shared(); sset1.add_surface(sph); } let brute_force_test = |ray:&Ray3D| { let mut result = SurfaceRayIntersection3::new(); for i in 0..num_samples/2 { let local_result = sset1.surface_at(i).read().unwrap().closest_intersection(ray); if local_result.distance < result.distance { result = local_result; } } return result; }; // Use second half of the samples as the query points for i in num_samples/2..num_samples { let ray = Ray3D::new(Vector3D::new_lst(get_sample_points3()[i]), Vector3D::new_lst(get_sample_dirs3()[i])); let actual = sset1.closest_intersection(&ray); let expected = brute_force_test(&ray); assert_eq!(expected.distance, actual.distance); assert_eq!(expected.point, actual.point); assert_eq!(expected.normal, actual.normal); assert_eq!(expected.is_intersecting, actual.is_intersecting); } // Now with translation instead of center let mut sset3 = SurfaceSet3::new_default(); for i in 0..num_samples/2 { let sph = Sphere3::builder() .with_radius(0.01) .with_center(Vector3D::new_default()) .with_translation(Vector3D::new_lst(get_sample_points3()[i])) .make_shared(); sset3.add_surface(sph); } for i in num_samples/2..num_samples { let ray = Ray3D::new(Vector3D::new_lst(get_sample_points3()[i]), Vector3D::new_lst(get_sample_dirs3()[i])); let actual = sset3.closest_intersection(&ray); let expected = brute_force_test(&ray); assert_eq!(expected.distance, actual.distance); assert_eq!(expected.point, actual.point); assert_eq!(expected.normal, actual.normal); assert_eq!(expected.is_intersecting, actual.is_intersecting); }
fn closest_normal_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn closest_normal_local(&self, other_point: &Vector3D) -> Vector3D
[src]use vox_geometry_rust::surface3::*; use vox_geometry_rust::surface_set3::SurfaceSet3; use vox_geometry_rust::sphere3::*; use vox_geometry_rust::vector3::{Vector3D, Vector3}; use vox_geometry_rust::unit_tests_utils::*; let mut sset1 = SurfaceSet3::new_default(); let num_samples = get_number_of_sample_points3(); // Use first half of the samples as the centers of the spheres for i in 0..num_samples/2 { let sph = Sphere3::builder() .with_radius(0.01) .with_center(Vector3D::new_lst(get_sample_points3()[i])) .make_shared(); sset1.add_surface(sph); } let brute_force_search = |pt:&Vector3D| { let mut min_dist3 = f64::MAX; let mut result = Vector3D::new_default(); for i in 0..num_samples/2 { let local_result = sset1.surface_at(i).read().unwrap().closest_normal(pt); let closest_pt = sset1.surface_at(i).read().unwrap().closest_point(pt); let local_dist3 = pt.distance_squared_to(closest_pt); if local_dist3 < min_dist3 { min_dist3 = local_dist3; result = local_result; } } return result; }; // Use second half of the samples as the query points for i in num_samples/2..num_samples { let actual = sset1.closest_normal(&Vector3D::new_lst(get_sample_points3()[i])); let expected = brute_force_search(&Vector3D::new_lst(get_sample_points3()[i])); assert_eq!(expected, actual); } // Now with translation instead of center let mut sset3 = SurfaceSet3::new_default(); for i in 0..num_samples/2 { let sph = Sphere3::builder() .with_radius(0.01) .with_center(Vector3D::new_default()) .with_translation(Vector3D::new_lst(get_sample_points3()[i])) .make_shared(); sset3.add_surface(sph); } for i in num_samples/2..num_samples { let actual = sset3.closest_normal(&Vector3D::new_lst(get_sample_points3()[i])); let expected = brute_force_search(&Vector3D::new_lst(get_sample_points3()[i])); assert_eq!(expected, actual); }
fn intersects_local(&self, ray_local: &Ray3D) -> bool
[src]
fn intersects_local(&self, ray_local: &Ray3D) -> bool
[src]use vox_geometry_rust::surface3::*; use vox_geometry_rust::surface_set3::SurfaceSet3; use vox_geometry_rust::sphere3::*; use vox_geometry_rust::vector3::{Vector3D, Vector3}; use vox_geometry_rust::ray3::Ray3D; use vox_geometry_rust::unit_tests_utils::*; let mut sset1 = SurfaceSet3::new_default(); let num_samples = get_number_of_sample_points3(); // Use first half of the samples as the centers of the spheres for i in 0..num_samples/2 { let sph = Sphere3::builder() .with_radius(0.01) .with_center(Vector3D::new_lst(get_sample_points3()[i])) .make_shared(); sset1.add_surface(sph); } let brute_force_test = |ray:&Ray3D| { for i in 0..num_samples/2 { if sset1.surface_at(i).read().unwrap().intersects(ray) { return true; } } return false; }; // Use second half of the samples as the query points for i in num_samples/2..num_samples { let ray = Ray3D::new(Vector3D::new_lst(get_sample_points3()[i]), Vector3D::new_lst(get_sample_dirs3()[i])); let actual = sset1.intersects(&ray); let expected = brute_force_test(&ray); assert_eq!(expected, actual); } // Now with translation instead of center let mut sset3 = SurfaceSet3::new_default(); for i in 0..num_samples/2 { let sph = Sphere3::builder() .with_radius(0.01) .with_center(Vector3D::new_default()) .with_translation(Vector3D::new_lst(get_sample_points3()[i])) .make_shared(); sset3.add_surface(sph); } for i in num_samples/2..num_samples { let ray = Ray3D::new(Vector3D::new_lst(get_sample_points3()[i]), Vector3D::new_lst(get_sample_dirs3()[i])); let actual = sset3.intersects(&ray); let expected = brute_force_test(&ray); assert_eq!(expected, actual); }
fn closest_distance_local(&self, other_point: &Vector3D) -> f64
[src]
fn closest_distance_local(&self, other_point: &Vector3D) -> f64
[src]use vox_geometry_rust::surface3::*; use vox_geometry_rust::surface_set3::SurfaceSet3; use vox_geometry_rust::sphere3::*; use vox_geometry_rust::vector3::{Vector3D, Vector3}; use vox_geometry_rust::unit_tests_utils::*; let mut sset1 = SurfaceSet3::new_default(); let num_samples = get_number_of_sample_points3(); // Use first half of the samples as the centers of the spheres for i in 0..num_samples/2 { let sph = Sphere3::builder() .with_radius(0.01) .with_center(Vector3D::new_lst(get_sample_points3()[i])) .make_shared(); sset1.add_surface(sph); } let brute_force_search = |pt:&Vector3D| { let mut min_dist = f64::MAX; for i in 0..num_samples/2 { let local_dist = sset1.surface_at(i).read().unwrap().closest_distance(pt); if local_dist < min_dist { min_dist = local_dist; } } return min_dist; }; // Use second half of the samples as the query points for i in num_samples/2..num_samples { let actual = sset1.closest_distance(&Vector3D::new_lst(get_sample_points3()[i])); let expected = brute_force_search(&Vector3D::new_lst(get_sample_points3()[i])); assert_eq!(expected, actual); } // Now with translation instead of center let mut sset3 = SurfaceSet3::new_default(); for i in 0..num_samples/2 { let sph = Sphere3::builder() .with_radius(0.01) .with_center(Vector3D::new_default()) .with_translation(Vector3D::new_lst(get_sample_points3()[i])) .make_shared(); sset3.add_surface(sph); } for i in num_samples/2..num_samples { let actual = sset3.closest_distance(&Vector3D::new_lst(get_sample_points3()[i])); let expected = brute_force_search(&Vector3D::new_lst(get_sample_points3()[i])); assert_eq!(expected, actual); }
fn is_inside_local(&self, other_point_local: &Vector3D) -> bool
[src]
fn is_inside_local(&self, other_point_local: &Vector3D) -> bool
[src]use vox_geometry_rust::surface3::*; use vox_geometry_rust::surface_set3::SurfaceSet3; use vox_geometry_rust::sphere3::*; use vox_geometry_rust::plane3::*; use vox_geometry_rust::bounding_box3::*; use vox_geometry_rust::transform3::*; use vox_geometry_rust::quaternion::*; use vox_geometry_rust::vector3::{Vector3D, Vector3}; let domain = BoundingBox3D::new(Vector3D::new_default(), Vector3D::new(1.0, 2.0, 1.0)); let offset = Vector3D::new(1.0, 2.0, 3.0); let plane = Plane3::builder() .with_normal(Vector3D::new(0.0, 1.0, 0.0)) .with_point(Vector3D::new(0.0, 0.25 * domain.height(), 0.0)) .make_shared(); let sphere = Sphere3::builder() .with_center(domain.mid_point()) .with_radius(0.15 * domain.width()) .make_shared(); let surface_set = SurfaceSet3::builder() .with_surfaces(vec![plane, sphere]) .with_transform(Transform3::new(offset, QuaternionD::new_default())) .make_shared(); assert_eq!(surface_set.read().unwrap().is_inside(&(Vector3D::new(0.5, 0.25, 0.5) + offset)), true); assert_eq!(surface_set.read().unwrap().is_inside(&(Vector3D::new(0.5, 1.0, 0.5) + offset)), true); assert_eq!(surface_set.read().unwrap().is_inside(&(Vector3D::new(0.5, 1.5, 0.5) + offset)), false);
fn update_query_engine(&self)
[src]
fn update_query_engine(&self)
[src]use vox_geometry_rust::surface3::*; use vox_geometry_rust::surface_set3::SurfaceSet3; use vox_geometry_rust::sphere3::*; use vox_geometry_rust::plane3::*; use vox_geometry_rust::bounding_box3::*; use vox_geometry_rust::transform3::*; use vox_geometry_rust::quaternion::*; use vox_geometry_rust::vector3::{Vector3D, Vector3}; let sphere = Sphere3::builder().with_center(Vector3D::new(-1.0, 1.0, 2.0)).with_radius(0.5).make_shared(); let surface_set = SurfaceSet3::builder() .with_surfaces(vec![sphere.clone()]) .with_transform(Transform3::new(Vector3D::new(1.0, 2.0, -1.0), QuaternionD::new_default())) .make_shared(); let bbox1 = surface_set.read().unwrap().bounding_box(); assert_eq!(BoundingBox3D::new(Vector3D::new(-0.5, 2.5, 0.5), Vector3D::new(0.5, 3.5, 1.5)).upper_corner, bbox1.upper_corner); assert_eq!(BoundingBox3D::new(Vector3D::new(-0.5, 2.5, 0.5), Vector3D::new(0.5, 3.5, 1.5)).lower_corner, bbox1.lower_corner); surface_set.write().unwrap().transform = Transform3::new(Vector3D::new(3.0, -4.0, 7.0), QuaternionD::new_default()); surface_set.write().unwrap().update_query_engine(); let bbox3 = surface_set.read().unwrap().bounding_box(); assert_eq!(BoundingBox3D::new(Vector3D::new(1.5, -3.5, 8.5), Vector3D::new(2.5, -2.5, 9.5)).upper_corner, bbox3.upper_corner); assert_eq!(BoundingBox3D::new(Vector3D::new(1.5, -3.5, 8.5), Vector3D::new(2.5, -2.5, 9.5)).lower_corner, bbox3.lower_corner); sphere.write().unwrap().transform = Transform3::new(Vector3D::new(-6.0, 9.0, 2.0), QuaternionD::new_default()); surface_set.write().unwrap().update_query_engine(); let bbox3 = surface_set.read().unwrap().bounding_box(); assert_eq!(BoundingBox3D::new(Vector3D::new(-4.5, 5.5, 10.5), Vector3D::new(-3.5, 6.5, 11.5)).upper_corner, bbox3.upper_corner); assert_eq!(BoundingBox3D::new(Vector3D::new(-4.5, 5.5, 10.5), Vector3D::new(-3.5, 6.5, 11.5)).lower_corner, bbox3.lower_corner); // Plane is unbounded. Total bbox should ignore it. let plane = Plane3::builder().with_normal(Vector3D::new(1.0, 0.0, 0.0)).make_shared(); surface_set.write().unwrap().add_surface(plane); surface_set.write().unwrap().update_query_engine(); let bbox4 = surface_set.read().unwrap().bounding_box(); assert_eq!(BoundingBox3D::new(Vector3D::new(-4.5, 5.5, 10.5), Vector3D::new(-3.5, 6.5, 11.5)).upper_corner, bbox4.upper_corner); assert_eq!(BoundingBox3D::new(Vector3D::new(-4.5, 5.5, 10.5), Vector3D::new(-3.5, 6.5, 11.5)).lower_corner, bbox4.lower_corner);
fn is_bounded(&self) -> bool
[src]
fn is_bounded(&self) -> bool
[src]use vox_geometry_rust::surface3::*; use vox_geometry_rust::surface_set3::SurfaceSet3; use vox_geometry_rust::sphere3::*; use vox_geometry_rust::plane3::*; use vox_geometry_rust::bounding_box3::*; use vox_geometry_rust::vector3::{Vector3D, Vector3}; use vox_geometry_rust::unit_tests_utils::*; let mut sset1 = SurfaceSet3::new_default(); let domain = BoundingBox3D::new(Vector3D::new_default(), Vector3D::new(1.0, 2.0, 1.0)); let plane = Plane3::builder() .with_normal(Vector3D::new(0.0, 1.0, 0.0)) .with_point(Vector3D::new(0.0, 0.25 * domain.height(), 0.0)) .make_shared(); let sphere = Sphere3::builder() .with_center(domain.mid_point()) .with_radius(0.15 * domain.width()) .make_shared(); let surface_set = SurfaceSet3::builder().with_surfaces(vec![plane, sphere]).make_shared(); assert_eq!(surface_set.read().unwrap().is_bounded(), false); let cp = surface_set.read().unwrap().closest_point(&Vector3D::new(0.5, 0.4, 0.5)); let answer = Vector3D::new(0.5, 0.5, 0.5); assert_eq!(answer.is_similar(&cp, Some(1.0e-9)), true);
fn is_valid_geometry(&self) -> bool
[src]
fn is_valid_geometry(&self) -> bool
[src]use vox_geometry_rust::surface3::*; use vox_geometry_rust::surface_set3::SurfaceSet3; use vox_geometry_rust::sphere3::*; use vox_geometry_rust::plane3::*; use vox_geometry_rust::bounding_box3::*; use vox_geometry_rust::vector3::{Vector3D, Vector3}; use vox_geometry_rust::unit_tests_utils::*; let surfaceSet = SurfaceSet3::builder().make_shared(); assert_eq!(surfaceSet.read().unwrap().is_valid_geometry(), false); let domain = BoundingBox3D::new(Vector3D::new_default(), Vector3D::new(1.0, 2.0, 1.0)); let plane = Plane3::builder() .with_normal(Vector3D::new(0.0, 1.0, 0.0)) .with_point(Vector3D::new(0.0, 0.25 * domain.height(), 0.0)) .make_shared(); let sphere = Sphere3::builder() .with_center(domain.mid_point()) .with_radius(0.15 * domain.width()) .make_shared(); let surfaceSet3 = SurfaceSet3::builder().with_surfaces(vec![plane, sphere]).make_shared(); assert_eq!(surfaceSet3.read().unwrap().is_valid_geometry(), true); surfaceSet3.write().unwrap().add_surface(surfaceSet); assert_eq!(surfaceSet3.read().unwrap().is_valid_geometry(), false);
fn view(&self) -> &Surface3Data
[src]
impl Surface3 for SurfaceToImplicit3
[src]
impl Surface3 for SurfaceToImplicit3
[src]fn closest_point_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn bounding_box_local(&self) -> BoundingBox3D
[src]
fn closest_intersection_local(&self, ray: &Ray3D) -> SurfaceRayIntersection3
[src]
fn closest_normal_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn intersects_local(&self, ray: &Ray3D) -> bool
[src]
fn closest_distance_local(&self, other_point: &Vector3D) -> f64
[src]
fn update_query_engine(&self)
[src]
fn is_bounded(&self) -> bool
[src]
fn is_valid_geometry(&self) -> bool
[src]
fn view(&self) -> &Surface3Data
[src]
impl Surface3 for Triangle3
[src]
impl Surface3 for Triangle3
[src]fn closest_point_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn bounding_box_local(&self) -> BoundingBox3D
[src]
fn closest_intersection_local(&self, ray: &Ray3D) -> SurfaceRayIntersection3
[src]
fn closest_normal_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn intersects_local(&self, ray: &Ray3D) -> bool
[src]
fn view(&self) -> &Surface3Data
[src]
impl Surface3 for TriangleMesh3
[src]
impl Surface3 for TriangleMesh3
[src]fn closest_point_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn closest_point_local(&self, other_point: &Vector3D) -> Vector3D
[src]use vox_geometry_rust::vector3::Vector3D; use vox_geometry_rust::triangle_mesh3::TriangleMesh3; use vox_geometry_rust::unit_tests_utils::*; use std::io::Cursor; use vox_geometry_rust::surface3::Surface3; let mut buffer = Cursor::new(get_cube_tri_mesh3x3x3obj()); let mut mesh = TriangleMesh3::new_default(None, None); mesh.read_obj_buffer(&mut buffer); let brute_force_search = |pt:&Vector3D| { let mut min_dist2 = f64::MAX; let mut result = Vector3D::new_default(); for i in 0..mesh.number_of_triangles() { let tri = mesh.triangle(i); let local_result = tri.closest_point(pt); let local_dist2 = pt.distance_squared_to(local_result); if local_dist2 < min_dist2 { min_dist2 = local_dist2; result = local_result; } } return result; }; let num_samples = get_number_of_sample_points3(); for i in 0..num_samples { let actual = mesh.closest_point(&Vector3D::new_lst(get_sample_points3()[i])); let expected = brute_force_search(&Vector3D::new_lst(get_sample_points3()[i])); assert_eq!(expected, actual); }
fn bounding_box_local(&self) -> BoundingBox3D
[src]
fn bounding_box_local(&self) -> BoundingBox3D
[src]use vox_geometry_rust::vector3::Vector3D; use vox_geometry_rust::bounding_box3::BoundingBox3D; use vox_geometry_rust::triangle_mesh3::TriangleMesh3; use vox_geometry_rust::unit_tests_utils::*; use std::io::Cursor; use vox_geometry_rust::surface3::Surface3; let mut buffer = Cursor::new(get_cube_tri_mesh3x3x3obj()); let mut mesh = TriangleMesh3::new_default(None, None); mesh.read_obj_buffer(&mut buffer); let aabb = BoundingBox3D::new(Vector3D::new(-0.5, -0.5, -0.5), Vector3D::new(0.5, 0.5, 0.5)); assert_eq!(aabb.lower_corner, mesh.bounding_box().lower_corner); assert_eq!(aabb.upper_corner, mesh.bounding_box().upper_corner);
fn closest_intersection_local(&self, ray: &Ray3D) -> SurfaceRayIntersection3
[src]
fn closest_intersection_local(&self, ray: &Ray3D) -> SurfaceRayIntersection3
[src]use vox_geometry_rust::vector3::Vector3D; use vox_geometry_rust::ray3::Ray3D; use vox_geometry_rust::triangle_mesh3::TriangleMesh3; use vox_geometry_rust::unit_tests_utils::*; use std::io::Cursor; use vox_geometry_rust::surface3::*; use vox_geometry_rust::assert_delta; let mut buffer = Cursor::new(get_cube_tri_mesh3x3x3obj()); let mut mesh = TriangleMesh3::new_default(None, None); mesh.read_obj_buffer(&mut buffer); let num_samples = get_number_of_sample_points3(); let brute_force_test = |ray:&Ray3D| { let mut result = SurfaceRayIntersection3::new(); for i in 0..mesh.number_of_triangles() { let tri = mesh.triangle(i); let local_result = tri.closest_intersection(ray); if local_result.distance < result.distance { result = local_result; } } return result; }; for i in 0..num_samples { let ray = Ray3D::new(Vector3D::new_lst(get_sample_points3()[i]), Vector3D::new_lst(get_sample_dirs3()[i])); let actual = mesh.closest_intersection(&ray); let expected = brute_force_test(&ray); assert_delta!(expected.distance, actual.distance, f64::EPSILON); assert_eq!(expected.point.is_similar(&actual.point, None), true); assert_eq!(expected.normal, actual.normal); assert_eq!(expected.is_intersecting, actual.is_intersecting); }
fn closest_normal_local(&self, other_point: &Vector3D) -> Vector3D
[src]
fn closest_normal_local(&self, other_point: &Vector3D) -> Vector3D
[src]use vox_geometry_rust::vector3::Vector3D; use vox_geometry_rust::triangle_mesh3::TriangleMesh3; use vox_geometry_rust::unit_tests_utils::*; use std::io::Cursor; use vox_geometry_rust::surface3::Surface3; let mut buffer = Cursor::new(get_sphere_tri_mesh5x5obj()); let mut mesh = TriangleMesh3::new_default(None, None); mesh.read_obj_buffer(&mut buffer); let brute_force_search = |pt:&Vector3D| { let mut min_dist2 = f64::MAX; let mut result = Vector3D::new_default(); for i in 0..mesh.number_of_triangles() { let tri = mesh.triangle(i); let local_result = tri.closest_normal(pt); let closest_pt = tri.closest_point(pt); let local_dist2 = pt.distance_squared_to(closest_pt); if local_dist2 < min_dist2 { min_dist2 = local_dist2; result = local_result; } } return result; }; let num_samples = get_number_of_sample_points3(); for i in 0..num_samples { let actual = mesh.closest_normal(&Vector3D::new_lst(get_sample_points3()[i])); let expected = brute_force_search(&Vector3D::new_lst(get_sample_points3()[i])); assert_eq!(expected.is_similar(&actual, Some(1.0e-9)), true); }
fn intersects_local(&self, ray_local: &Ray3D) -> bool
[src]
fn intersects_local(&self, ray_local: &Ray3D) -> bool
[src]use vox_geometry_rust::vector3::Vector3D; use vox_geometry_rust::ray3::Ray3D; use vox_geometry_rust::triangle_mesh3::TriangleMesh3; use vox_geometry_rust::unit_tests_utils::*; use std::io::Cursor; use vox_geometry_rust::surface3::Surface3; let mut buffer = Cursor::new(get_cube_tri_mesh3x3x3obj()); let mut mesh = TriangleMesh3::new_default(None, None); mesh.read_obj_buffer(&mut buffer); let num_samples = get_number_of_sample_points3(); let brute_force_test = |ray:&Ray3D| { for i in 0..mesh.number_of_triangles() { let tri = mesh.triangle(i); if tri.intersects(ray) { return true; } } return false; }; for i in 0..num_samples { let ray = Ray3D::new(Vector3D::new_lst(get_sample_points3()[i]), Vector3D::new_lst(get_sample_dirs3()[i])); let actual = mesh.intersects(&ray); let expected = brute_force_test(&ray); assert_eq!(expected, actual); }
fn closest_distance_local(&self, other_point_local: &Vector3D) -> f64
[src]
fn closest_distance_local(&self, other_point_local: &Vector3D) -> f64
[src]use vox_geometry_rust::vector3::Vector3D; use vox_geometry_rust::triangle_mesh3::TriangleMesh3; use vox_geometry_rust::unit_tests_utils::*; use std::io::Cursor; use vox_geometry_rust::surface3::Surface3; let mut buffer = Cursor::new(get_cube_tri_mesh3x3x3obj()); let mut mesh = TriangleMesh3::new_default(None, None); mesh.read_obj_buffer(&mut buffer); let brute_force_search = |pt:&Vector3D| { let mut min_dist = f64::MAX; for i in 0..mesh.number_of_triangles() { let tri = mesh.triangle(i); let local_result = tri.closest_distance(pt); if local_result < min_dist { min_dist = local_result; } } return min_dist; }; let num_samples = get_number_of_sample_points3(); for i in 0..num_samples { let actual = mesh.closest_distance(&Vector3D::new_lst(get_sample_points3()[i])); let expected = brute_force_search(&Vector3D::new_lst(get_sample_points3()[i])); assert_eq!(expected, actual); }
fn is_inside_local(&self, other_point_local: &Vector3D) -> bool
[src]
fn is_inside_local(&self, other_point_local: &Vector3D) -> bool
[src]use vox_geometry_rust::vector3::Vector3D; use vox_geometry_rust::ray3::Ray3D; use vox_geometry_rust::triangle_mesh3::TriangleMesh3; use vox_geometry_rust::unit_tests_utils::*; use std::io::Cursor; use vox_geometry_rust::surface3::Surface3; let mut buffer = Cursor::new(get_cube_tri_mesh3x3x3obj()); let mut mesh = TriangleMesh3::new_default(None, None); mesh.read_obj_buffer(&mut buffer); let num_samples = get_number_of_sample_points3(); for i in 0..num_samples { let p = Vector3D::new_lst(get_sample_points3()[i]); let actual = mesh.is_inside(&p); let expected = mesh.bounding_box().contains(&p); assert_eq!(expected, actual); }