Comment gerer la vitesse dans la courbe de bezier en c++
bekha
Messages postés6Date d'inscriptionmercredi 9 avril 2008StatutMembreDernière intervention 2 décembre 2008
-
27 mai 2008 à 14:27
luhtor
Messages postés2023Date d'inscriptionmardi 24 septembre 2002StatutMembreDernière intervention28 juillet 2008
-
28 mai 2008 à 12:59
salut, en faite je suis un peu bloqué ayant programmé ma courbe de bezier je voulais ajouter la vitesse mais je sais comment on fait tout ce je sais c
typedef struct point_3d { // Structure for a 3 dimensional point (NEW)
double x, y, z;
} point_3d;
typedef struct bpatch { // Structure for a 3rd degree bezier patch (NEW)
point_3danchors[4][4]; // 4x4 grid of anchor points
GLuint dlBPatch; // Display List for Bezier Patch
GLuint texture; // Texture for the patch
}
BEZIER_PATCH;
HDC hDC=NULL; // Private GDI Device Context
HGLRC hRC=NULL; // Permanent Rendering Context
HWND hWnd=NULL; // Holds Our Window Handle
HINSTANCE hInstance; // Holds The Instance Of The Application
DEVMODE DMsaved; // Saves the previous screen settings (NEW)
//bool
keys[256]; // Array Used For The Keyboard Routine
//bool
active=TRUE; // Window Active Flag Set To TRUE By Default
//bool
fullscreen=TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default
GLfloat rotz = 0.0f; // Rotation about the Z axis
BEZIER_PATCH mybezier; // The bezier patch we're going to use (NEW)
BOOL showCPoints=TRUE;// Toggles displaying the control point grid (NEW)
int divs = 7; // Number of intrapolations (conrols poly resolution) (NEW)
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc
glEnd(); // End the haptic shape.
hlEndShape();
//End the haptic frame.
hlEndFrame();
// Multiplies a point and a constant. Don't just use '*'
double point_3d pointTimes(double c, point_3d p) {
p.x *= c; p.y *= c; p.z *= c;
return p;
}
// Function for quick point creation
double point_3d makePoint(double a, double b, double c) {
point_3d p;
p.x a; p.y b; p.z = c;
return p;
}
// Calculates 3rd degree polynomial based on array of 4 points
// and a single variable (u) which is generally between 0 and 1
point_3d Bernstein(float u, point_3d *p) {
point_3d a, b, c, d, r;
a = pointTimes(pow(u,3), p[0]);
b = pointTimes(3*pow(u,2)*(1-u), p[1]);
c = pointTimes(3*u*pow((1-u),2), p[2]);
d = pointTimes(pow((1-u),3), p[3]);
r = pointAdd(pointAdd(a, b), pointAdd(c, d));
return r;
}
A voir également:
Comment gerer la vitesse dans la courbe de bezier en c++
bekha
Messages postés6Date d'inscriptionmercredi 9 avril 2008StatutMembreDernière intervention 2 décembre 2008 28 mai 2008 à 10:19
c'est à dire l'algo qui permet de gerer la vitesse a un point de la courbe. Je suis preneur pour toute idée ou toute implementation quasi-toute-faite...