Example #1
0
        static public Vecteur3D operator *(float f, Vecteur3D v)             //produit par un réel
        {
            Vecteur3D z = v;

            z.multiplier_par(f);
            return(z);
        }
Example #2
0
        static public Vecteur3D operator +(Vecteur3D v, Vecteur3D w)             //somme vectorielle
        {
            Vecteur3D z = v;

            v.additionner(w);
            return(z);
        }
Example #3
0
		void Triangle(Graphics g, Color couleur, Vecteur3D v1, Vecteur3D v2, Vecteur3D v3)
		{
			Vecteur3D n = NormaleTriangle( v1, v2, v3 ) ;
			float angle = AngleEntre( n, _directionLumiere ) ;
			float X, Y ;
			
			try
			{
			Coord2DFrom3D( v1, out X, out Y ) ;
			points[0].X = (int)Math.Round(X) ;
			points[0].Y = (int)Math.Round(Y) ;
			
			Coord2DFrom3D( v2, out X, out Y ) ;
			points[1].X = (int)Math.Round(X) ;
			points[1].Y = (int)Math.Round(Y) ;
			
			Coord2DFrom3D( v3, out X, out Y ) ;
			points[2].X = (int)Math.Round(X) ;
			points[2].Y = (int)Math.Round(Y) ;
			
			using ( Brush b = calculeCouleur( couleur, angle, v1.z))
				g.FillPolygon( b, points ) ;
			}
			catch
			{}
		}
Example #4
0
        protected void Coord2DFrom3D(Vecteur3D v, out float xScreen, out float yScreen)
        {
            xScreen = _centreX + (v.x * (_zEcran - _zCamera) / (v.z - _zCamera));
            yScreen = _centreY + (v.y * (_zEcran - _zCamera) / (v.z - _zCamera));

            if (xScreen > MAX_COORD)
            {
                xScreen = MAX_COORD;
            }
            else
            if (xScreen < MIN_COORD)
            {
                xScreen = MIN_COORD;
            }


            if (yScreen > MAX_COORD)
            {
                yScreen = MAX_COORD;
            }
            else if (yScreen < MIN_COORD)
            {
                yScreen = MIN_COORD;
            }
        }
Example #5
0
        static public Vecteur3D operator ^(Vecteur3D v, Vecteur3D w)             //produit vectoriel
        {
            Vecteur3D z = new Vecteur3D(
                v.y * w.z - w.y * v.z,
                v.z * w.x - w.z * v.x,
                v.x * w.y - w.x * v.y
                );

            return(z);
        }
Example #6
0
        protected Vecteur3D NormaleTriangle(Vecteur3D P1, Vecteur3D P2, Vecteur3D P3)
        {
            Vecteur3D v = new Vecteur3D();

            v.x = (P2.y - P1.y) * (P3.z - P1.z) - (P2.z - P1.z) * (P3.y - P1.y);
            v.y = (P2.z - P1.z) * (P3.x - P1.x) - (P2.x - P1.x) * (P3.z - P1.z);
            v.z = (P2.x - P1.x) * (P3.y - P1.y) - (P2.y - P1.y) * (P3.x - P1.x);
            v.Normalize();
            return(v);
        }
Example #7
0
        static public void RotateAxeZ(Vecteur3D v, float Theta, float axeX, float axeY)
        {
            float CosTheta = (float)Math.Cos(Theta);
            float SinTheta = (float)Math.Sin(Theta);

            float px = CosTheta * (v.x - axeX) - SinTheta * (v.y - axeY) + axeX;
            float py = SinTheta * (v.x - axeX) + CosTheta * (v.y - axeY) + axeY;

            v.x = px;
            v.y = py;
        }
Example #8
0
		void PlaceAnneau(int i)
		{
			float profondeur = _zMax - _zMin ;
			float ecart = profondeur / NB_ANNEAUX ;
			float z = _zCamera + (i*ecart) ;
			
			for (int j = 0; j < TAILLE_ANNEAU; j++)
			{
				double angle = (Math.PI*2.0*j) / (double)TAILLE_ANNEAU ;
				_anneaux[i,j] = new Vecteur3D( _CentreAnneauX + (float)(RAYON_ANNEAU * Math.Cos(angle)), _CentreAnneauY + (float)(RAYON_ANNEAU * Math.Sin(angle)),z) ;
			}			
		}
Example #9
0
 float prodscal(Vecteur3D v)
 {
     return(x * v.x + y * v.y + z * v.z);
 }
Example #10
0
 void additionner(Vecteur3D a)
 {
     x = x + a.x; y = y + a.y; z = z + a.z;
 }
Example #11
0
        protected float AngleEntre(Vecteur3D v1, Vecteur3D v2)
        {
            float angle = v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;

            return((float)Math.Acos(angle));
        }