Introduction: The goal of this project is to create an animated scene of Bézier curves. It must be in 3D (i.e., Z cannot

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
correctanswer
Posts: 43759
Joined: Sat Aug 07, 2021 7:38 am

Introduction: The goal of this project is to create an animated scene of Bézier curves. It must be in 3D (i.e., Z cannot

Post by correctanswer »

Introduction The Goal Of This Project Is To Create An Animated Scene Of Bezier Curves It Must Be In 3d I E Z Cannot 1
Introduction The Goal Of This Project Is To Create An Animated Scene Of Bezier Curves It Must Be In 3d I E Z Cannot 1 (114.17 KiB) Viewed 63 times
Introduction: The goal of this project is to create an animated scene of Bézier curves. It must be in 3D (i.e., Z cannot be constant). You must have at least 5 curves. The curves must somehow be "different" from each other. That could mean rotated, scaled, different points, etc. Just translated is not enough. Requirements: 1. Create a scene of at least five 3D Bézier curves. 2. What the scene looks like is up to you. 10 of the 100 points are given if you deliberately make it look like something at least somewhat recognizeable. 3. How you color the scene is up to you. 4. How you animate the scene is up to you. 5. How many points you use to draw each curve is up to you. But, use enough to make the curves look smooth. 6. Animate each curve by changing the position of one (or more) points per curve based on the Time variable you have been creating in the last couple of projects. 7. Be able to turn the control points on and off. 8. Be able to turn the control lines on and off. 9. Enable the following keys: 'f Freese/un-freeze the animation Possible Way to Organize the Data struct Point { float x0, yo, z0; // initial coordinates float x, y, z; // animated coordinates }; struct Curve
{ float r, g, b; Point po, p1, p2, p3; }; Curve Curves [NUMCURVES]; // if you are creating a pattern of curves Curve Stem; // if you are not Reminder: The Cubic Bézier Equation P = (1.-t)3P0+ 3t(1.-t)2P1 + 3t2(1.-t)P2 + t3P3 0.≤t≤ 1.
Rotating a Point an Angle about the X Axis Around a Center void RotateX( Point *p, float deg, float xc, float yc, float zc ) { float rad deg * (M_PI/180.f); // radians float xp->x0 XC; float y p->ye - yc; = float z = p->z - Zc; float xp = x; z* sin(rad); float yp = y*cos (rad) float zp = y*sin(rad) + z*cos(rad); p->x= xp + Xc; р->у = ур +yc; p->z = zp+zC; } Rotating a Point an Angle about the Y Axis Around a Center void RotateY( Point *p, float deg, float xc, float yc, float zc ) { float rad deg * (M_PI/180.f); // radians float xp->x0 - Xc; float y p->ye yc; float z = p->z@ - ZC; float xp = x*cos(rad) + z*sin(rad); float yp= y; float zp = -x* sin(rad) + z*cos(rad); p->x= xp + Xc; р->у = ур +yc; p->z = zp + ZC; }
Rotating a Point an Angle about the Z Axis Around a Center void Rotatez( Point *p, float deg, float xc, float yc, float zc ) { float rad = deg* (M_PI/180.f); // radians float xp->x0 XC; float y = p->ye ус; float z = p->ze ZC; float xp = x*cos(rad) y* sin(rad); float yp = x*sin (rad) + y*cos(rad); float zp= z; p->x= xp + Xc; p->y = ypyc; p->z = zp + zc; } Drawing a Bézier Curve glLineWidth( 3.); glColor3f(r, g, b); glBegin( GL_LINE_STRIP ); for(int it = 0; it <= NUMPOINTS; it++) { float t= (float)it/ (float) NUMPOINTS; float omt 1.f - t; float x = omt*omt*omt* p0.x + 3. f*t*omt*omt*p1.x + 3.f*t*t*omt*p2.x + t*t*t*p3.x; float y = omt*omt*omt*p.y + 3.f*t*omt*omt*p1.y + 3. f*t*t*omt*p2.y + t*t*t*p3.y;
float z = omt*omt*omt* p0.z + 3. f*t*omt*omt*p1.z + 3.f*t*t*omt*p2.z + t*t*t*p3.z; glVertex3f(x, y, z); } glEnd(); glLineWidth( 1.); How Did Joe Graphics Get That Nice Color Progression? He used the hue-saturation-value color scale and the HsvRgb() function that is included in your sample code. As long as you are using angles to locate points, you can use that same angle to assign a hue and then turn it into an RGB. See slide # 53 of the Getting Started notes.
Register for solutions, replies, and use board search function. Answer Happy Forum is an archive of questions covering all technical subjects across the Internet.
Post Reply