当前位置: 首页>>代码示例>>C++>>正文


C++ vector3::normalize方法代码示例

本文整理汇总了C++中vector3::normalize方法的典型用法代码示例。如果您正苦于以下问题:C++ vector3::normalize方法的具体用法?C++ vector3::normalize怎么用?C++ vector3::normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vector3的用法示例。


在下文中一共展示了vector3::normalize方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setFace

//for only world
void UITextBox::setFace(vector3 right, vector3 down){
	right.normalize();
	down.normalize();

	direction = right;
	this->down = down;
}
开发者ID:Vorril,项目名称:Cubesprawl,代码行数:8,代码来源:UITextBox.cpp

示例2:

vector3<float> get_rotation_axis(vector3<float> u, vector3<float> v) {
	u.normalize();
	v.normalize();
	// fix linear case
	if (u == v || u == -v) {
		v[0] += 0.1;
		v[1] += 0.0;
		v[2] += 0.1;
		v.normalize();
	}
	return u.cross(v);
}
开发者ID:channguyen,项目名称:solar-system-opengl-window,代码行数:12,代码来源:main.cpp

示例3: get_rotation_angle

double get_rotation_angle(vector3<float> u, vector3<float> v) {
	u.normalize();
	v.normalize();
	double cosine_theta = u.dot(v);
	// domain of arccosine is [-1, 1]
	if (cosine_theta > 1) {
		cosine_theta = 1;
	}
	if (cosine_theta < -1) {
		cosine_theta = -1;
	}
	double angle = acos(cosine_theta);
	return angle;
}
开发者ID:channguyen,项目名称:solar-system-opengl-window,代码行数:14,代码来源:main.cpp

示例4: findCenterAndNormal

  bool OBRing::findCenterAndNormal(vector3 & center, vector3 &norm1, vector3 &norm2)
  {
    OBMol *mol= this->_parent;
    int j= 0;
    const int nA= this->_path.size();
    vector3 tmp;

    center.Set(0.0,0.0,0.0);
    norm1.Set(0.0,0.0,0.0);
    norm2.Set(0.0,0.0,0.0);
    for (j = 0; j != nA; ++j)
      {
        center += (mol->GetAtom(_path[j]))->GetVector();
      }
    center/= double(nA);

    for (j = 0; j != nA; ++j)
      {
        vector3 v1= (mol->GetAtom(_path[j]))->GetVector() - center;
        vector3 v2= (mol->GetAtom(_path[j+1==nA?0:j+1]))->GetVector() - center;
        tmp= cross(v1,v2);
        norm1+= tmp;
      }
    norm1/= double(nA);
    norm1.normalize();
    norm2= norm1;
    norm2 *= -1.0;
    return(true);
  }
开发者ID:arkose,项目名称:openbabel,代码行数:29,代码来源:ring.cpp

示例5: computeSDFNormal

inline bool computeSDFNormal(const UT_VoxelArrayF *g_col, int iX, int iY, int iZ, vector3 &norm){
	//Make sure this is a border cell?????
	if (g_col->getValue(iX, iY, iZ) <= 0)
		return false;
	norm[0] = g_col->getValue(iX-1,iY,iZ) - g_col->getValue(iX+1,iY,iZ);
	norm[1] = g_col->getValue(iX,iY-1,iZ) - g_col->getValue(iX,iY+1,iZ);
	norm[2] = g_col->getValue(iX,iY,iZ-1) - g_col->getValue(iX,iY,iZ+1);
	norm.normalize();
	return true;
}
开发者ID:Azmisov,项目名称:snow,代码行数:10,代码来源:SIM_SnowSolver.c

示例6:

void matrix4::initialize_camera(vector3 forward, vector3 up) {
    forward.normalize();
    vector3 f = forward;
    up.normalize();
    vector3 r = up;
    r.normalize();
    r.cross_product(f);
    vector3 u = f;
    u.cross_product(r);
    initialize_identity();
    set_at(0, 0, r.get_x());
    set_at(0, 1, r.get_y());
    set_at(0, 2, r.get_z());
    set_at(1, 0, u.get_x());
    set_at(1, 1, u.get_y());
    set_at(1, 2, u.get_z());
    set_at(2, 0, f.get_x());
    set_at(2, 1, f.get_y());
    set_at(2, 2, f.get_z());
}
开发者ID:ArkaneCow,项目名称:thirdpillow,代码行数:20,代码来源:matrix4.cpp

示例7: LevelDelimiter

Wall::Wall(vector3 pos, vector3 dir, vector3 vertex1, vector3 vertex2, vector3 vertex3, vector3 vertex4, string texture_path):
            LevelDelimiter(pos,dir.normalize(),vector3(0.0,1.0,0.0),vertex1,vertex2,vertex3,vertex4,texture_path)
{
    const_term = dir[0]*vertices[0]+dir[1]*vertices[1]+dir[2]*vertices[2];
    square_root = sqrt(dir[0]*dir[0]+dir[1]*dir[1]+dir[2]*dir[2]);
    build_bounding_box();
    GLfloat orizzontal = ((int)length)/2;
    GLfloat vertical = ((int)height)/5;
    GLfloat texc[8] = { 0.0,0.0,
            orizzontal,0.0,
            orizzontal,vertical,
            0.0,vertical};
    memcpy(texcoords, texc, sizeof(GLfloat)*8);
}
开发者ID:lpuglia,项目名称:Open-Portal,代码行数:14,代码来源:Wall.cpp

示例8: LineSearch

  // LineSearch 
  //
  // atom: coordinates of atom at iteration k (x_k)
  // direction: search direction ( d = -grad(x_0) )
  //
  // ALGORITHM:
  // 
  // step = 1
  // for (i = 1 to 100) {                max steps = 100
  //   e_k = energy(x_k)                 energy of current iteration
  //   x_k = x_k + step * d              update coordinates
  //   e_k+1 = energy(x_k+1)             energy of next iteration
  //   
  //   if (e_k+1 < e_k)
  //     step = step * 1.2               increase step size
  //   if (e_k+1 > e_k) {
  //     x_k = x_k - step * d            reset coordinates to previous iteration
  //     step = step * 0.5               reduce step size
  //   }
  //   if (e_k+1 == e_k)
  //     end                             convergence criteria reached, stop
  // }
  vector3 OBForceField::LineSearch(OBAtom *atom, vector3 &direction)
  {
    double e_n1, e_n2, step;
    vector3 old_xyz, orig_xyz, xyz_k, dir(0.0, 0.0, 0.0);

    step = 0.2;
    direction.normalize();
    orig_xyz = atom->GetVector();
    
    e_n1 = Energy(false); // calculate e_k
    
    unsigned int i;
    for (i=0; i<100; i++) {
      old_xyz = atom->GetVector();
      
      xyz_k = atom->GetVector() + direction*step;
      atom->SetVector(xyz_k);  // update coordinates
    
      e_n2 = Energy(false); // calculate e_k+1
      
      // convergence criteria, this is 10 times the default convergence
      // of SteepestDescent or ConjugateGradients. A higher precision here 
      // only takes longer with the same result.
      if (IsNear(e_n2, e_n1, 1.0e-7))
        break;

      if (e_n2 > e_n1) { // decrease stepsize
        step *= 0.5;
        atom->SetVector(old_xyz);
      }
      if (e_n2 < e_n1) {  // increase stepsize
        e_n1 = e_n2;
        step *= 1.2;
        if (step > 1.0)
          step = 1.0;
      }
      
    }
    //cout << "LineSearch steps: " << i << endl;

    dir = atom->GetVector() - orig_xyz;
    atom->SetVector(orig_xyz);     

    // cutoff accuracy
    if (dir.length() < 1.0e-8)
      return VZero;

    return dir;
  }
开发者ID:candycode,项目名称:openbabel,代码行数:71,代码来源:forcefield.cpp

示例9: toAxisAngle

void quater::toAxisAngle(vector3& axis, double& angle) const
{
/*

#ifdef USE_D3DFUNC
	buggy.-.-
	D3DXQuaternionToAxisAngle(*this, axis, &angle);	
#else
	*/
	vector3 log;
	log.ln(*this);
	axis.normalize(log);
	angle=log.length()*2.f;

//#endif
}
开发者ID:kswoo3740,项目名称:Computer_Graphics,代码行数:16,代码来源:quater.cpp

示例10: inverse_kinematics

void Scene::inverse_kinematics(vector3 pos, vector3 normal, float &a1, float &a2, float &a3, float &a4, float &a5)
{
	float l1 = .91f, l2 = .81f, l3 = .33f, dy = .27f, dz = .26f;
	normal.normalize();
	vector3 pos1 = pos + normal * l3;
	float e = sqrtf(pos1.z*pos1.z + pos1.x*pos1.x - dz*dz);
	a1 = atan2(pos1.z, -pos1.x) + atan2(dz, e);
	vector3 pos2(e, pos1.y - dy, .0f);
	a3 = -acosf(min(1.0f, (pos2.x*pos2.x + pos2.y*pos2.y - l1*l1 - l2*l2)
		/ (2.0f*l1*l2)));
	float k = l1 + l2 * cosf(a3), l = l2 * sinf(a3);
	a2 = -atan2(pos2.y, sqrtf(pos2.x*pos2.x + pos2.z*pos2.z)) - atan2(l, k);
	vector3 normal1;
	normal1 = vector3(RotateRadMatrix44('y', -a1) *
		vector4(normal.x, normal.y, normal.z, .0f));
	normal1 = vector3(RotateRadMatrix44('z', -(a2 + a3)) *
		vector4(normal1.x, normal1.y, normal1.z, .0f));
	a5 = acosf(normal1.x);
	a4 = atan2(normal1.z, normal1.y);
}
开发者ID:monkog,项目名称:PUMA,代码行数:20,代码来源:gk2_scene.cpp


注:本文中的vector3::normalize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。