Next: Geometrical Display Up: Tina View Previous: The 2D Graphics Camera   Contents

# The 3D Graphics Camera

The 3D camera determines the way 3D `world' points are mapped into pixel coordinates in the graphics window. In Tina 3D floating point positions are specified by a structure

```typedef struct vec3
{
Ts_id ts_id;                /* Tina structure identifier */
float   el[3];
}       Vec3;
```

they can be created with calls to

```Vec2 vec3(double x, double y, double z)
```

of the form

```Vec3 p;
p = vec3(0.0, 0.5, 1.0).
```
```(For further details on vector algebra see the Tinamath documentation).
The 3D projection function can be called explicitly with
```
```Ipos tv_proj3(Tv *tv, Vec3 p)
```

3D cameras are usually specified initially by a call to

```void    tv_camera3(Tv * tv, Vec3 centre, double radius, double pscale,
Vec3 aim, Vec3 down)
```
This sets the 3D camera used by tv so that:
1. The point centre appears in the centre of the image
2. A ball of the given radius about the central point can be seen in the tv window.
3. The camera is pointing in direction aim
4. The vector down in the world will point vertically downwards in the tv window.
5. When perspective projection mode is set the camera will be at a distance pscale*radius from centre (pscale = 3.0 usually gives obvious but not exaggerated perspective).

This `implicit' camera specification is very convenient for visualisation of 3D objects - usually Tina provides a function which gives the centre and radius of an enclosing sphere for such objects, calling tv_camera3 above with varying aim and up directions allows the observer to move round the object, keeping it always in the field of view (see the zoom facility below).

Next: Geometrical Display Up: Tina View Previous: The 2D Graphics Camera   Contents
root 2018-12-17