00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "Vect2Matrix.h"
00010 #include "math_graphics.h"
00011
00012
00013 int * getVect2iMatElement( const Vect2iMatrix * mat, int row, int col )
00014 {
00015 return (int *) getMatElement( mat, row, col ) ;
00016 }
00017
00018 void copyVect2iMatElement( sciMatrix * mat,
00019 int row ,
00020 int col ,
00021 const int copyValue[2] )
00022 {
00023 copyMatElement( mat, row, col, copyValue, 2 * sizeof(int) ) ;
00024 }
00025
00026 void rotateVect2iMatrix( Vect2iMatrix * mat, int center[2], double angle )
00027 {
00028 double cosAngle = cos( angle ) ;
00029 double sinAngle = sin( angle ) ;
00030 int i ;
00031 int j ;
00032 for ( i = 0 ; i < mat->nbRow; i++ )
00033 {
00034 for ( j = 0 ; j < mat->nbCol ; j++ )
00035 {
00036 int * curElement = getVect2iMatElement( mat, i, j ) ;
00037 iRotate2Dim( curElement, center, cosAngle, sinAngle, curElement ) ;
00038 }
00039 }
00040 }
00041
00042 void translateVect2iMatrix( Vect2iMatrix * mat, int trans[2] )
00043 {
00044 int i ;
00045 int j ;
00046 for ( i = 0 ; i < mat->nbRow ; i++ )
00047 {
00048 for ( j = 0 ; j < mat->nbCol ; j++ )
00049 {
00050 int * curElement = getVect2iMatElement( mat, i, j ) ;
00051 iTranslate2D( curElement, trans, curElement ) ;
00052 }
00053 }
00054 }
00055
00056 void homothVect2iMatrix( Vect2iMatrix * mat, int center[2], double factors[2] )
00057 {
00058 int i ;
00059 int j ;
00060 for ( i = 0 ; i < mat->nbRow; i++ )
00061 {
00062 for ( j = 0 ; j < mat->nbCol ; j++ )
00063 {
00064 int * curElement = getVect2iMatElement( mat, i, j ) ;
00065 iHomothety2D( curElement, center, factors, curElement ) ;
00066 }
00067 }
00068 }
00069
00070 double * getVect2dMatElement( const Vect2dMatrix * mat, int row, int col )
00071 {
00072 return (double *) getMatElement( mat, row, col ) ;
00073 }
00074
00075 void copyVect2dMatElement( Vect2dMatrix * mat,
00076 int row ,
00077 int col ,
00078 const double copyValue[2] )
00079 {
00080 copyMatElement( mat, row, col, copyValue, 2 * sizeof(double) ) ;
00081 }
00082
00083 void rotateVect2dMatrix( Vect2dMatrix * mat, double center[2], double angle )
00084 {
00085 double cosAngle = cos( angle ) ;
00086 double sinAngle = sin( angle ) ;
00087 int i ;
00088 int j ;
00089 for ( i = 0 ; i < mat->nbRow ; i++ )
00090 {
00091 for ( j = 0 ; j < mat->nbCol ; j++ )
00092 {
00093 double * curElement = getVect2dMatElement( mat, i, j ) ;
00094 rotate2Dim( curElement, center, cosAngle, sinAngle, curElement ) ;
00095 }
00096 }
00097 }
00098
00099 void translateVect2dMatrix( Vect2dMatrix * mat, double trans[2] )
00100 {
00101 int i ;
00102 int j ;
00103 for ( i = 0 ; i < mat->nbRow ; i++ )
00104 {
00105 for ( j = 0 ; j < mat->nbCol ; j++ )
00106 {
00107 double * curElement = getVect2dMatElement( mat, i, j ) ;
00108 translate2D( curElement, trans, curElement ) ;
00109 }
00110 }
00111 }
00112
00113 void homothVect2dMatrix( Vect2dMatrix * mat, double center[2], double factors[2] )
00114 {
00115 int i ;
00116 int j ;
00117 for ( i = 0 ; i < mat->nbRow; i++ )
00118 {
00119 for ( j = 0 ; j < mat->nbCol ; j++ )
00120 {
00121 double * curElement = getVect2dMatElement( mat, i, j ) ;
00122 homothety2D( curElement, center, factors, curElement ) ;
00123 }
00124 }
00125 }
00126