Main Content

sim3d.sensors.RaytraceSensor

Implement ray tracing

Since R2024b

    Description

    Use the sim3d.sensors.RaytraceSensor object to implement ray tracing in the scene. You can configure the ray origins, directions, and lengths to adjust the ray trace sensor pattern for your scene and test scenario. After you create a sim3d.sensors.RaytraceSensor object, you can modify aspects of the actor object by setting property values.

    Creation

    Description

    raytraceSensor = sim3d.sensors.RaytraceSensor() creates a default sim3d.sensors.RaytraceSensor object in the 3D environment.

    raytraceSensor = sim3d.sensors.RaytraceSensor(Name=Value) specifies options using one or more optional name-value arguments. For example, to create a ray trace sensor with number of bounces per ray as 3, set NumberOfBounces to 3.

    Input Arguments

    expand all

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: raytraceSensor = sim3d.sensors.RaytraceSensor(ActorName='RaytraceSensor',NumberOfBounces=3)

    Name of actor, specified as a character array or string. If you do not specify an actor name, then the software assigns the actor an autogenerated name. Use this argument to set the name of the sim3d.sensors.RaytraceSensor object.

    Note

    If you specify the same name as an actor that already exists, then the software appends actor name you specify with a unique identifier.

    Relative translation (x,y,z) of the actor object to its parent actor, specified as a real 1-by-3 vector, in m. Use Translation to change the position of the sim3d.sensors.RaytraceSensor object in the 3D environment along the X, Y, and Z axes of the coordinate system. When you add an actor to the 3D environment, the default parent actor is the Scene Origin at (0,0,0).

    Example: Translation=[1 2 1]

    Relative rotation (roll, pitch, yaw) of the actor object to its parent actor, specified as a real 1-by-3 vector, in rad. Use Rotation to rotate the sim3d.sensors.RaytraceSensor object in the 3D environment.

    Example: Rotation=[pi/4 pi/8 pi/2]

    Ray origin relative to sensor location, specified as a real-valued N-by-3 array of the form [X, Y, Z], in meters. N is the number of rays. If you mount the sensor to an actor by setting Parent to the name of that actor, then X, Y, and Z are in the world coordinate system, where:

    • The X-axis points forward and away from the viewer.

    • The Y-axis points to the right.

    • The Z-axis points up.

    Example: RayOrigins=zeros(10,3)

    Normalized ray direction relative to sensor location, specified as a real-valued N-by-3 array of the form [X, Y, Z]. N is the number of rays. The units are dimensionless. If you mount the sensor to an actor by setting Parent to the name of that actor, then X, Y, and Z are in the world coordinate system, where:

    • The X-axis points forward and away from the viewer.

    • The Y-axis points to the right.

    • The Z-axis points up.

    Example: RayDirections=ones(10,3)

    Maximum total ray length of a multi-bounce trace path, specified as a real-valued N-by-1 vector, in meters. N is the number of rays.

    Example: RayLengths=ones(10,1)*10

    Number of bounces per ray that a trace may have before terminating, B, specified as a positive integer.

    Example: NumberOfBounces=0

    Option to visualize trace lines, specified as 0 (false) if the trace line visualization is not enabled or 1 (true) if it is enabled.

    Example: VisualizeTraceLines=1

    Option to enable optimization, specified as 0 (false) if the optimization is not enabled or 1 (true) if it is enabled. Enabling this argument allows the object to perform concurrent traces. Enable this argument when the number of traces is large and your machine has multiple cores.

    Example: EnableOptimization=1

    Properties

    expand all

    Parent of actor, specified as a handle to the parent actor object. After you add an actor to the sim3d.World object, the default parent actor is the Scene Origin at (0,0,0). Use Parent to set any actor in the 3D environment as the parent actor of a sim3d.sensors.RaytraceSensor object.

    This property is read-only.

    Children of actor, specified as a structure. Each field of the structure contains a handle to the child of a sim3d.sensors.RaytraceSensor object.

    Parent world, specified as a handle to the parent sim3d.World object. You can use this property only if the sim3d.sensors.RaytraceSensor object is added to the parent sim3d.World object.

    This property is read-only.

    Unique ID of the sensor, specified as a real positive scalar.

    Data Types: uint32

    Relative translation (x,y,z) of the actor object to its parent actor, specified as a real 1-by-3 vector, in m. Use Translation to change the position of the sim3d.sensors.RaytraceSensor object in the 3D environment along the X, Y, and Z axes of the coordinate system. When you add an actor to the 3D environment, the default parent actor is the Scene Origin at (0,0,0).

    Example: raytraceSensor.Translation = [1 2 1]

    Relative rotation (roll, pitch, yaw) of the actor object to its parent actor, specified as a real 1-by-3 vector, in rad. Use Rotation to rotate the sim3d.sensors.RaytraceSensor object in the 3D environment.

    Example: raytraceSensor.Rotation = [pi/4 pi/8 pi/2]

    Type of actor mobility to respond to physics, move the actor during simulation, or both, specified as 'sim3d.utils.MobilityTypes.Movable' or 'sim3d.utils.MobilityTypes.Static'.

    Example: raytraceSensor.Mobility = sim3d.utils.MobilityTypes.Movable

    Data Types: sim3d.utils.MobilityTypes

    Ray origin relative to sensor location, specified as a real-valued N-by-3 array of the form [X, Y, Z], in meters. N is the number of rays. If you mount the sensor to an actor by setting Parent to the name of that actor, then X, Y, and Z are in the world coordinate system, where:

    • The X-axis points forward and away from the viewer.

    • The Y-axis points to the right.

    • The Z-axis points up.

    Example: raytraceSensor.RayOrigins = zeros(10,3)

    Normalized ray direction relative to sensor location, specified as a real-valued N-by-3 array of the form [X, Y, Z]. N is the number of rays. The units are dimensionless. If you mount the sensor to an actor by setting Parent to the name of that actor, then X, Y, and Z are in the world coordinate system, where:

    • The X-axis points forward and away from the viewer.

    • The Y-axis points to the right.

    • The Z-axis points up.

    Example: raytraceSensor.RayDirections = ones(10,3)

    Maximum total ray length of a multi-bounce trace path, specified as a real-valued N-by-1 vector, in meters. N is the number of rays.

    Example: raytraceSensor.RayLengths = ones(10,1)*10

    Number of bounces per ray that a trace may have before terminating, B, specified as a positive integer.

    Example: raytraceSensor.NumberOfBounces = 0

    Option to visualize trace lines, specified as 0 (false) if the trace line visualization is not enabled or 1 (true) if it is enabled.

    Example: raytraceSensor.VisualizeTraceLines = 1

    Object Functions

    readReturn target data using ray tracing

    Version History

    Introduced in R2024b