| 1 |
/* Libvisual-plugins - Standard plugins for libvisual |
| 2 |
* |
| 3 |
* Copyright (C) 2000, 2001 Remi Arquier <[email protected]> |
| 4 |
* |
| 5 |
* Authors: Remi Arquier <[email protected]> |
| 6 |
* Dennis Smit <[email protected]> |
| 7 |
* |
| 8 |
* $Id: projection.c,v 1.3 2005/12/20 18:49:12 synap Exp $ |
| 9 |
* |
| 10 |
* This program is free software; you can redistribute it and/or modify |
| 11 |
* it under the terms of the GNU General Public License as |
| 12 |
* published by the Free Software Foundation; either version 2 |
| 13 |
* of the License, or (at your option) any later version. |
| 14 |
* |
| 15 |
* This program is distributed in the hope that it will be useful, |
| 16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
* GNU General Public License for more details. |
| 19 |
* |
| 20 |
* You should have received a copy of the GNU General Public License |
| 21 |
* along with this program; if not, write to the Free Software |
| 22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 |
*/ |
| 24 |
|
| 25 |
#include <math.h> |
| 26 |
|
| 27 |
void rotation_3d (float *x, float *y, float *z, float alpha, float beta, |
| 28 |
float gamma) |
| 29 |
{ |
| 30 |
float nx, ny; |
| 31 |
float cosga = cos (gamma), singa = sin (gamma), cosal = cos (alpha), sinal = |
| 32 |
sin (alpha); |
| 33 |
|
| 34 |
|
| 35 |
nx = cosga * *x - singa * *y; |
| 36 |
ny = cosal * (singa * *x + cosga * *y) - sinal * *z; |
| 37 |
*z = sinal * (singa * *x + cosga * *y) + cosal * *z; |
| 38 |
|
| 39 |
*x = nx; |
| 40 |
*y = ny; |
| 41 |
|
| 42 |
} |
| 43 |
|
| 44 |
void perspective (float *x, float *y, float *z, int persp, int dist_cam) |
| 45 |
{ |
| 46 |
float foc_cam = 100,aux; |
| 47 |
aux = (foc_cam + persp) / (dist_cam + persp - *z); |
| 48 |
*x = *x * aux; |
| 49 |
*y = *y * aux; |
| 50 |
} |
| 51 |
|