Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

vpbezier.cpp

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 // ChangeLog
00006 // Jan 10, 2005 - Bruno de Oliveira Schneider
00007 // - Fixed DoxyGen class description.
00008 // - Removed previously commented methods: GetPointAsPoint and GetPointAsVertex.
00009 // Oct 08, 2004 - Bruno de Oliveira Schneider
00010 // - Code typing has been cleaned. DoxyGen documentation started.
00011 // - Removed "vp" prefix from every method name.
00012 // - Removed "#include <stdio.h>" from implementation.
00013 // - Added "dealocateControlPoints" attribute.
00014 // - Created destructor (old one did not free memory and was commented out).
00015 // - Added "GetPoint" method.
00016 // - Most methods changed to reflect the changes in VPCurve.
00017 // Aug 10, 2000 - Anderson Maciel
00018 // - Classes declaration.
00019 
00020 #include "vpbezier.h"
00021 #include <cassert>
00022 
00023 VPBezier::VPBezier() {
00024     // Allocate memory
00025     controlPoints.reserve(4);
00026     // Set the number of control points. It seems to exist no way of setting the
00027     // number of control points without initializing all of them.
00028     controlPoints.assign(4,VPPoint4D::ORIGIN());
00029 }
00030 
00031 VPPoint4D VPBezier::GetControlPoint(int i) {
00032     assert (i < 4);
00033     assert (i >= 0);
00034     return controlPoints[i];
00035 }
00036 
00037 void VPBezier::SetControlPoint(int i, const VPPoint4D& point) {
00038     assert (i < 4);
00039     assert (i >= 0);
00040     controlPoints[i] = point;
00041 }
00042 
00043 void VPBezier::GetPoint(double t, VPPoint4D* result) {
00044     double invT = 1-t; // Cache this common value
00045     double t2 = t*t; // Cache this common value
00046     VPPoint4D p0(controlPoints[0]);
00047     VPPoint4D p1(controlPoints[1]);
00048     VPPoint4D p2(controlPoints[2]);
00049     VPPoint4D p3(controlPoints[3]);
00050 
00051     p0 *= invT*invT*invT;
00052     p1 *= 3*t*invT*invT;
00053     p2 *= 3*t2*invT;
00054     p3 *= t2*t;
00055     *result = p0 + p1 + p2 + p3;
00056 }

Generated on Tue Sep 6 10:00:02 2005 for VPAT by  doxygen 1.4.4