Comment gerer la vitesse dans la courbe de bezier en c++

bekha Messages postés 6 Date d'inscription mercredi 9 avril 2008 Statut Membre Dernière intervention 2 décembre 2008 - 27 mai 2008 à 14:27
luhtor Messages postés 2023 Date d'inscription mardi 24 septembre 2002 Statut Membre Dernière intervention 28 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();



}


// Adds 2 points. Don't just use '+' ;)
point_3d pointAdd(double
point_3d p, point_3d q) {
p.x += q.x; p.y += q.y; p.z += q.z;
return p;
}

// 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;
}

4 réponses

luhtor Messages postés 2023 Date d'inscription mardi 24 septembre 2002 Statut Membre Dernière intervention 28 juillet 2008 6
27 mai 2008 à 22:10
La vitesse de quoi ?
0
bekha Messages postés 6 Date d'inscription mercredi 9 avril 2008 Statut Membre Dernière intervention 2 décembre 2008
28 mai 2008 à 09:48
beman
0
bekha Messages postés 6 Date d'inscription mercredi 9 avril 2008 Statut Membre Derniè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...

Merci d'avance.
beman
0
luhtor Messages postés 2023 Date d'inscription mardi 24 septembre 2002 Statut Membre Dernière intervention 28 juillet 2008 6
28 mai 2008 à 12:59
Je comprends pas ce que tu veux dire. Un point de la courbe n'a pas de vitesse, il a une tangente tout au plus.
0
Rejoignez-nous