1.1. Core Classes¶
- class raysect.core.ray.Ray¶
Describes a line in space with an origin and direction.
Note that the core Ray class only implements the geometry calculations needed for intersections and is not capable of any optical simulations. For that you would need the derived optical Ray class (
raysect.optical.ray.Ray
).- Parameters
- Variables
>>> from raysect.core import Point3D, Vector3D >>> from raysect.core.ray import Ray as CoreRay >>> >>> intersection = world.hit(CoreRay(Point3D(0, 0, 0,), Vector3D(1, 0, 0))) >>> if intersection is not None: >>> # do something with the intersection results
- copy()¶
Copy this ray to a new Ray instance.
- Parameters
- Returns
A new Ray instance.
- Return type
>>> from raysect.core import Point3D, Vector3D >>> from raysect.core.ray import Ray as CoreRay >>> >>> a = CoreRay(Point3D(0, 0, 0,), Vector3D(1, 0, 0)) >>> a.copy() Ray(Point3D(0.0, 0.0, 0.0), Vector3D(1.0, 0.0, 0.0), inf)
- point_on()¶
Returns the point on the ray at the specified parametric distance from the ray origin.
Positive values correspond to points forward of the ray origin, along the ray direction.
- Parameters
t (double) – The distance along the ray.
- Returns
A point at distance t along the ray direction measured from its origin.
- Return type
>>> from raysect.core import Point3D, Vector3D >>> from raysect.core.ray import Ray as CoreRay >>> >>> a = CoreRay(Point3D(0, 0, 0,), Vector3D(1, 0, 0)) >>> a.point_on(2) Point3D(2.0, 0.0, 0.0)
- class raysect.core.intersection.Intersection¶
Describes the result of a ray-primitive intersection.
Users are unlikely to instance this class themselves, in most cases they will need to inspect this object as the result of a Ray-Primitive intersection encountered in the world.hit() method (
raysect.core.scenegraph.world.World.hit
).The inside and outside points are launch points for rays emitted from the hit point on the surface. Rays cannot be launched from the hit point directly as they risk re-intersecting the same surface due to numerical accuracy. The inside and outside points are slightly displaced from the primitive surface at a sufficient distance to prevent re-intersection due to numerical accuracy issues. The inside_point is shifted backwards into the surface relative to the surface normal. The outside_point is equivalently shifted away from the surface in the direction of the surface normal.
- Parameters
ray (Ray) – The incident ray object (world space).
ray_distance (double) – The distance of the intersection along the ray path.
primitive (Primitive) – The intersected primitive object.
hit_point (Point3D) – The point of intersection between the ray and the primitive (primitive local space).
inside_point (Point3D) – The interior ray launch point (primitive local space).
outside_point (Point3D) – The exterior ray launch point (primitive local space).
normal (Normal3D) – The surface normal (primitive local space)
exiting (bool) – True if the ray is exiting the surface, False otherwise.
world_to_primitive (AffineMatrix3D) – A world to primitive local transform matrix.
primitive_to_world (AffineMatrix3D) – A primitive local to world transform matrix.
- Variables
exiting (bool) – True if the ray is exiting the surface, False otherwise.
hit_point (Point3D) – The point of intersection between the ray and the primitive (primitive local space).
inside_point (Point3D) – The interior ray launch point (primitive local space).
normal (Normal3D) – The surface normal (primitive local space).
outside_point (Point3D) – The exterior ray launch point (primitive local space).
primitive (Primitive) – The primitive object that was intersected by the Ray.
primitive_to_world (AffineMatrix3D) – The primitive’s local to world transform matrix.
ray (Ray) – The incident ray object (world space).
ray_distance (double) – The distance of the intersection along the ray path.
world_to_primitive (AffineMatrix3D) – A world to primitive local transform matrix.
>>> from raysect.core import Point3D, Vector3D >>> from raysect.core.ray import Ray as CoreRay >>> >>> intersection = world.hit(CoreRay(Point3D(0, 0, 0,), Vector3D(1, 0, 0))) >>> if intersection is not None: >>> hit_point = intersection.hit_point.transform(intersection.primitive_to_world) >>> # do something with the hit point...