Main Content

Create Scene from 3-D Shapes and Perform Ray Tracing Analysis

Since R2025a

This example shows how to model a scene using 3-D shapes and perform ray tracing on it. This example models a tunnel and performs ray tracing for two dipole antennas installed inside this tunnel with one antenna as a transmitter and the other as a receiver.

Create Tunnel Using 3-D Shapes

Create a tunnel of length 10 m using the shape.Box and shape.Cylinder objects, and their functions.

Specify the length of the tunnel in meters.

tunnelLength = 10;

To create the base of the tunnel, create a box and delete its three faces.

s1 = shape.Box(Length=1.8,Height=tunnelLength,Width=1.5,Center=[0 -0.75 0]);
s2 = deleteFaces(s1,[1 2 3]);
[~] = rotateX(s2,90);
figure
show(s2)
title("Tunnel Base")

Figure contains an axes object. The axes object with title Tunnel Base, xlabel x (m), ylabel y (m) contains 2 objects of type patch.

To create the tunnel dome structure, create a cylinder and subtract a box shape from it.

s3 = shape.Cylinder(Cap=[1 1],Radius=0.9,Height=tunnelLength);
s4 = shape.Box(Length=1.8,Height=tunnelLength,Width=0.9,Center=[0 -0.45 0]);
s5 = subtract(s3,s4);
[~] = rotateX(s5,90);
figure
show(s5)
title("Tunnel Dome")

Figure contains an axes object. The axes object with title Tunnel Dome, xlabel x (m), ylabel y (m) contains 2 objects of type patch.

Add the dome to the tunnel base.

s6 = add(s2,s5);
figure
show(s6)
title("Tunnel Structure Without Bottom Cavity")

Figure contains an axes object. The axes object with title Tunnel Structure Without Bottom Cavity, xlabel x (m), ylabel y (m) contains 3 objects of type patch.

Create a small cavity at the bottom of the tunnel along its length.

s7 = shape.Box(Length=0.3,Height=tunnelLength,Width=0.3,Center=[-0.75 -1.65 0]);
s8 = deleteFaces(s7,[1 2 3]);
[~] = rotateX(s8,90) 
s9 = add(s6,s8); 
figure
show(s9)
title("Tunnel Structure with Bottom Cavity")

Figure contains an axes object. The axes object with title Tunnel Structure with Bottom Cavity, xlabel x (m), ylabel y (m) contains 4 objects of type patch.

Remove the top and side faces of the cavity box to get the final tunnel shape.

removeFaces(s9,[1 16 17]);

Figure contains an axes object. The axes object with xlabel x-axis, ylabel y-axis contains 32 objects of type patch.

tunnelShape = s9;

Mesh the shape and extract the information on points and triangles of the mesh. Use this information to create a triangulation object. Write this information to an STL file.

[~] = mesh(tunnelShape,MaxEdgeLength=1.5);
[p,t] = exportMesh(tunnelShape);
tr = triangulation(t(:,1:3),p);
stlwrite(tr,"tunnel10m.stl");

Create Scene

Load the STL file as a scene model in a site viewer. Alternatively, you can also pass the triangulation object tr to the SceneModel property directly.

sv = siteviewer(SceneModel="tunnel10m.stl");

Tunnel visualization in the site viewer.

Create dipole antenna

Design a dipole antenna resonating at 455 MHz. Use this antenna at the transmitter and receiver sites. You can use other antennas from the antenna catalog or design your own antenna operating at a desired frequency.

f = 455e6;
antTxRx = design(dipole(Tilt=90,TiltAxis="X"),f);

Place transmitter and receiver at their locations

Use a txsite object to place the transmitter antenna at the entrance of the tunnel. Use an rxsite object to place the receiver antenna at the middle of the tunnel. You can vary the position of the receiver antenna to measure the signal strength at various locations.

tx = txsite(Antenna=antTxRx,CoordinateSystem="cartesian",AntennaPosition=[0.8;4.5;0],TransmitterFrequency=f);
rx = rxsite(Antenna=antTxRx,CoordinateSystem="cartesian",AntennaPosition=[-0.8;0;0]);

Create propagation model

Create a SBR ray tracing propagation model with 10 reflections for a concrete surface.

pm = propagationModel("raytracing",MaxNumReflections=10,CoordinateSystem="cartesian",SurfaceMaterial="concrete");

Compute the signal strength (power) in dBm.

ss = sigstrength(rx,tx,pm,Type="power")
ss = 
-12.0669

Perform Ray Tracing

Perform ray tracing and visualize the propagating rays.

raytrace(tx,rx,pm)

Raytracing for two dipole antennas installed inside the tunnel.

See Also

Objects

Functions

Topics