vrcoordm2vr
(To be removed) Convert MATLAB coordinates to VR coordinates
vrcoordm2vr
will be removed in a future release. For more information,
see Version History.
Syntax
Description
Examples
Translate an Object Along a Path
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
m
— Coordinates in MATLAB notation
3-element vector
Coordinates of a point in MATLAB notation, specified as a 3-element row vector.
Data Types: single
| double
Output Arguments
vr
— Coordinates in VRML notation
3-element vector
Coordinates of a point in VRML notation, returned as a 3-element row vector.
Data Types: single
| double
Version History
Introduced in R2019aR2023b: 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.
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)