Main Content

vrcoordm2vr

(To be removed) Convert MATLAB coordinates to VR coordinates

vrcoordm2vr will be removed in a future release. For more information, see Version History.

Description

vr = vrcoordm2vr(m) converts a point with coordinates in the MATLAB® coordinate system to the Virtual World coordinate system.

example

Examples

collapse all

This example shows translation specified in MATLAB coordinate system.

Create a vrworld object representing the virtual world and open it.

world = vrworld('vrmount'); 
open(world);
view(world); 

Identify the nodes in the virtual world using the nodes command.

nodes(world)
View1 (Viewpoint) [VR Car in the Mountains]
	Camera_car (Transform) [VR Car in the Mountains]
	VPfollow (Viewpoint) [VR Car in the Mountains]
	Automobile (Transform) [VR Car in the Mountains]
	Wheel (Shape) [VR Car in the Mountains]
	Tree1 (Group) [VR Car in the Mountains]
	Wood (Group) [VR Car in the Mountains]
	Canal (Shape) [VR Car in the Mountains]
	ElevApp (Appearance) [VR Car in the Mountains]
	River (Shape) [VR Car in the Mountains]
	Bridge (Shape) [VR Car in the Mountains]
	Road (Shape) [VR Car in the Mountains]
	Tunnel (Transform) [VR Car in the Mountains]

Access the Automobile vrnode object by assigning it to a handle.

car = world.Automobile
car = 

	vrnode object: 1-by-1

	Automobile (Transform) [VR Car in the Mountains]

Move the car along the first section of the road.

xz_my = zeros(12,3);

xz_my(:,2) = 1:12;
xz_my(:,1) = 3;
xz_my(:,3) = -0.25;

for idx = 1:length(xz_my)
   car.translation = vrcoordm2vr(xz_my(idx,:));
   vrdrawnow;
   pause(0.1);
end

Rotate the car a little to get to the second part of the road. This is done by setting the rotation property of the Automobile node.

car.rotation = [0 1 0 -0.7];
vrdrawnow;

Move the car through the second section of the road.

z2 = 12:26;
x2 = 3:1.4285:23;
y2 = -0.25 + zeros(size(z2));
xz_my2 = [x2' z2' y2'];

for idx = 1:length(xz_my2)
   car.translation = vrcoordm2vr(xz_my2(idx,:));
   vrdrawnow;
   pause(0.1);
end

Rotate the car once again to face the third stretch of the road and continue to the end.

car.rotation = [0 1 0 0];
x3 = 23:43;
z3 = 26 + zeros(size(x3));
y3 = -0.25 + zeros(size(z3));
xz_my3 = [x3' z3' y3'];
for idx = 1:length(xz_my3)
   car.translation = vrcoordm2vr(xz_my3(idx,:));
   vrdrawnow;
   pause(0.1);
end

Input Arguments

collapse all

Coordinates of a point in MATLAB notation, specified as a 3-element row vector.

Data Types: single | double

Output Arguments

collapse all

Coordinates of a point in VRML notation, returned as a 3-element row vector.

Data Types: single | double

Version History

Introduced in R2019a

collapse all

R2023b: To be removed

The vrcoordm2vr will be removed in a future release. Instead, use sim3d classes and Simulation 3D blocks to interface MATLAB and Simulink® with the Unreal Engine® 3D simulation environment. To get started, see Create 3D Simulations in Unreal Engine Environment.