本文整理汇总了C++中vector3类的典型用法代码示例。如果您正苦于以下问题:C++ vector3类的具体用法?C++ vector3怎么用?C++ vector3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vector3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: double
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);
}
示例2: setFace
//for only world
void UITextBox::setFace(vector3 right, vector3 down){
right.normalize();
down.normalize();
direction = right;
this->down = down;
}
示例3: Camera
Camera(vector3 p, vector3 d, vector3 u) {
position = p;
direction = d.normalized();
up = u.normalized();
up = (u - direction.projected(u)).normalized();
right = (direction ^ up).normalized();
}
示例4: translation_matrix
matrix4x4 translation_matrix(vector3 const& v)
{
return matrix4x4 (1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
v.x(), v.y(), v.z(), 1);
}
示例5: x
const vector3 vector3::operator / (const vector3 &v2) const
{
vector3 r;
r.x() = x() / v2.x();
r.y() = y() / v2.y();
r.z() = z() / v2.z();
return r;
}
示例6: acosf
float vector3::AngleBetweenVectors(const vector3& v0, const vector3& v1)
{
float d = v0.Dot(v1);
if ( d >= -1.f && d <= 1.f )
{
return acosf( d / ( v0.Length() * v1.Length() ) );
}
return 0.f;
}
示例7: get_rotation_axis
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);
}
示例8: vector3
vector3 vector3::Transform(const vector3& v, const matrix& m)
{
vector3 result = vector3(
(v.x() * m(0,0)) + (v.x() * m(1,0)) + (v.x() * m(2,0)) + m(3,0),
(v.y() * m(0,1)) + (v.y() * m(1,1)) + (v.y() * m(2,1)) + m(3,1),
(v.z() * m(0,2)) + (v.z() * m(1,2)) + (v.z() * m(2,2) ) + m(3,2));
return result;
}
示例9: SetData
//! Implements <a href="http://qsar.sourceforge.net/dicts/blue-obelisk/index.xhtml#calculateOrthogonalisationMatrix">blue-obelisk:calculateOrthogonalisationMatrix</a>
void OBUnitCell::SetData(const vector3 v1, const vector3 v2, const vector3 v3)
{
matrix3x3 m (v1, v2, v3);
_mOrtho.FillOrth(vectorAngle(v2,v3), // alpha
vectorAngle(v1,v3), // beta
vectorAngle(v1,v2), // gamma
v1.length(), // a
v2.length(), // b
v3.length()); // c
_mOrient = m.transpose() * _mOrtho.inverse();
_spaceGroup = NULL;
_spaceGroupName = "";
_lattice = OBUnitCell::Undefined;
}
示例10: 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;
}
示例11: FacePlane
///
// FacePlane()
//
// Which of the six face-plane(s) is point P outside of?
//
static
int FacePlane(const vector3& p)
{
int outcode;
outcode = 0;
if (p.x() > .5) outcode |= 0x01;
if (p.x() < -.5) outcode |= 0x02;
if (p.y() > .5) outcode |= 0x04;
if (p.y() < -.5) outcode |= 0x08;
if (p.z() > .5) outcode |= 0x10;
if (p.z() < -.5) outcode |= 0x20;
return(outcode);
}
示例12: nStabilizer
//Return size of stabilizer group of a Cartesian displacement (given Cartesian symmetry rotations)
inline int nStabilizer(const vector3<>& n, const std::vector< matrix3<> >& symCart)
{ int nStab = 0;
for(const matrix3<>& m: symCart)
if((n - m * n).length_squared() < symmThresholdSq * n.length_squared())
nStab++;
return nStab;
}
示例13: setrot
void matrix::setrot(vector3 p1,vector3 p2)
{
vector3 _ax=p1*p2;
_ax.selfnormalize();
double _th=p1.angle(p2);
setrot(_th,_ax);
}
示例14: atan2
void moon::display(const vector3 &moon_pos, const vector3 &sun_pos, double max_view_dist) const
{
vector3 moon_dir = moon_pos.normal();
double moon_size = max_view_dist/20;
float moon_azimuth = atan2(-moon_dir.y, moon_dir.x);
float moon_elevation = asin(moon_dir.z);
glsl_moon->use();
glsl_moon->set_gl_texture(*map_diffuse, loc_diffcol, 0);
glsl_moon->set_gl_texture(*map_normal, loc_nrml, 1);
// transform light into object space
matrix4 roth = matrix4::rot_z(-RAD_TO_DEG(moon_azimuth));
matrix4 rotv = matrix4::rot_y(-RAD_TO_DEG(moon_elevation));
matrix4 model_mat = roth*rotv;
vector3 l = model_mat.inverse() * sun_pos;
vector3 nl = vector3(-l.y, l.z, -l.x).normal(); // OpenGL coordinates
glsl_moon->set_uniform(loc_lightdir, nl);
// render moon
glPushMatrix();
model_mat.multiply_gl();
glTranslated(0.95*max_view_dist, 0, 0);
primitives::textured_quad(vector3f( 0, moon_size, moon_size),
vector3f( 0, -moon_size, moon_size),
vector3f( 0, -moon_size, -moon_size),
vector3f( 0, moon_size, -moon_size),
*map_diffuse).render_plain();
glPopMatrix();
}
示例15: dir
double controller::ray_traverse(vector3 const & direction) const
{
float coords[4];
direction.getAs4Values(coords);
vector3 dir(coords[0] * cos(-rotation) - coords[2] * sin(-rotation),
coords[1],
coords[0] * sin(-rotation) + coords[2] * cos(-rotation));
boost::lock_guard<boost::mutex> lock(mutex_);
core::line3d<f32> ray;
ray.start = position_ + vector3(0, 5, 0);
ray.end = position_ + vector3(0, 5, 0) + dir * 1000.0f;
core::vector3df intersection;
core::triangle3df hitTriangle;
scene::ISceneNode * selectedSceneNode =
collision_manager_->getSceneNodeAndCollisionPointFromRay(
ray,
intersection, // This will be the position of the collision
hitTriangle, // This will be the triangle hit in the collision
0, //IDFlag_IsPickable, // This ensures that only nodes that we have
// set up to be pickable are considered
0); // Check
return (intersection - position_).getLength();
}