Documentation

This is machine translation

Mouseover text to see original. Click the button below to return to the English version of the page.

vrcoordm2vr

Convert MATLAB coordinates to VR coordinates

Syntax

``vr = vrcoordm2vr(m)``

Description

example

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

Examples

collapse all

This example is a variation of the Car in the Mountains example, with the coordinates for 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`

Introduced in R2019a 