本文整理汇总了C++中ControlPointList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ControlPointList::size方法的具体用法?C++ ControlPointList::size怎么用?C++ ControlPointList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ControlPointList
的用法示例。
在下文中一共展示了ControlPointList::size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getControlPoints
CQIllustratorShapeNearestPoint2D
CQIllustratorShape::
nearestPoint(const CPoint2D &p, ControlType type) const
{
CQIllustratorShapeNearestPoint2D nearest;
ControlPointList points;
getControlPoints(points, type);
uint num_points = points.size();
for (uint i = 0; i < num_points; ++i) {
double dist = points[i]->distance(this, p);
nearest.updatePoint(points[i], dist);
}
return nearest;
}
示例2: integrate_actor
//------------------------------------------------------------------------------
/// Simple Euler integration
void integrate_actor( void ) {
int qi = 0;
bool failed = true;
SdS sds, sdsi;
unsigned int n = cplist.size();
for( unsigned int i = 2; i < n-1; i++ ) {
sdsi = catmullrom_arclength_map.at( i );
if( actor_ds < sdsi.first ) {
sds = catmullrom_arclength_map.at( i-1 );
qi = i;
failed = false;
break;
}
}
if( failed ) {
std::cout << "failed to find the next control point -> off the spline\n";
return; // failed to find the next control point -> off the spline
}
Eigen::MatrixXd C = CubicSpline::blend( catmullrom_M, cplist, qi );
double qi_ds = sdsi.second;
double qip_s = sds.first;
// where the actor will be in terms of arclength after the step is taken
double s1 = actor_dsdt * sim_dt + (actor_ds - qip_s);
double u = (double)s1 / (double)qi_ds;
Vector3 vi1 = CubicSpline::position( C, u );
// update the actor position
actor_position = vi1;
// advance the actor for next tick
actor_ds = s1 + qip_s;
// advance the sim time
sim_t += sim_dt;
Vector3 v_w = CubicSpline::tangent( C, u );
v_w.normalize();
double wdotup = Vector3::dot( v_w, actor_up );
double wdotforward = Vector3::dot( v_w, actor_forward );
double theta = acos(wdotforward);
if( wdotup < 0.0 ) {
theta = -theta; // pitch down
}
Matrix3 R = Matrix3::rotZ( theta );
actor_up = R * actor_up;
actor_up.normalize();
actor_forward = v_w;
actor_left = Vector3::cross( actor_forward, actor_up );
actor_left.normalize();
actor_transform = Matrix4( actor_forward(0), actor_up(0), actor_left(0), actor_position.x(),
actor_forward(1), actor_up(1), actor_left(1), actor_position.y(),
actor_forward(2), actor_up(2), actor_left(2), actor_position.z(),
0.0, 0.0, 0.0, 1.0 );
}
示例3: draw_spline
//------------------------------------------------------------------------------
// Spline Functions
//------------------------------------------------------------------------------
void draw_spline( const ECubicSplineBasis& basis ) {
glPushMatrix();
Eigen::MatrixXd M;
GLfloat material_Ka[4] = { 0.0, 0.0, 0.0, 1.0 };
GLfloat material_Kd[4] = { 0.0, 0.0, 0.0, 1.0 };
GLfloat material_Ks[4] = { 0.0, 0.0, 0.0, 1.0 };
GLfloat material_Ke[4] = { 0.0, 0.0, 0.0, 1.0 };
GLfloat material_Se = 10;
switch( basis ) {
case CUBIC_SPLINE_CATMULLROM:
default:
material_Ka[0] = catmullrom_Ka(0);
material_Ka[1] = catmullrom_Ka(1);
material_Ka[2] = catmullrom_Ka(2);
material_Kd[0] = catmullrom_Kd(0);
material_Kd[1] = catmullrom_Kd(1);
material_Kd[2] = catmullrom_Kd(2);
material_Ks[0] = catmullrom_Ks(0);
material_Ks[1] = catmullrom_Ks(1);
material_Ks[2] = catmullrom_Ks(2);
material_Ke[0] = catmullrom_Ke(0);
material_Ke[1] = catmullrom_Ke(1);
material_Ke[2] = catmullrom_Ke(2);
M = catmullrom_M;
break;
case CUBIC_SPLINE_B:
material_Ka[0] = bspline_Ka(0);
material_Ka[1] = bspline_Ka(1);
material_Ka[2] = bspline_Ka(2);
material_Kd[0] = bspline_Kd(0);
material_Kd[1] = bspline_Kd(1);
material_Kd[2] = bspline_Kd(2);
material_Ks[0] = bspline_Ks(0);
material_Ks[1] = bspline_Ks(1);
material_Ks[2] = bspline_Ks(2);
material_Ke[0] = bspline_Ke(0);
material_Ke[1] = bspline_Ke(1);
material_Ke[2] = bspline_Ke(2);
M = bspline_M;
break;
}
glMaterialfv(GL_FRONT, GL_AMBIENT, material_Ka);
glMaterialfv(GL_FRONT, GL_DIFFUSE, material_Kd);
glMaterialfv(GL_FRONT, GL_SPECULAR, material_Ks);
glMaterialfv(GL_FRONT, GL_EMISSION, material_Ke);
glMaterialf(GL_FRONT, GL_SHININESS, material_Se);
Vector3 vi, vi1;
unsigned int n = cplist.size();
glLineWidth( line_width );
glBegin(GL_LINES);
for( unsigned int i = 2; i < n-1; i++ ) {
Eigen::MatrixXd C = CubicSpline::blend( M, cplist, i );
std::vector<Vector3> points;
for( double u = 0.0; u < 1.0; u += 0.1 ) {
points.push_back( CubicSpline::position( C, u ) );
}
points.push_back( CubicSpline::position( C, 1.0 ) );
for( std::vector<Vector3>::iterator it = points.begin(); it != points.end(); it++ ) {
if( it == points.begin() ) {
vi = *it;
} else {
vi1 = *it;
glVertex3d( vi.x(), vi.y(), vi.z() );
glVertex3d( vi1.x(), vi1.y(), vi1.z() );
vi = *it;
}
}
}
glEnd();
glPopMatrix();
}