本文整理汇总了C++中vec3d类的典型用法代码示例。如果您正苦于以下问题:C++ vec3d类的具体用法?C++ vec3d怎么用?C++ vec3d使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vec3d类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Subtag
bool SubSurface::Subtag( const vec3d & center )
{
UpdatePolygonPnts(); // Update polygon vector
for ( int p = 0; p < ( int )m_PolyPntsVec.size(); p++ )
{
bool inPoly = PointInPolygon( vec2d( center.x(), center.y() ), m_PolyPntsVec[p] );
if ( inPoly && m_TestType() == vsp::INSIDE )
{
return true;
}
else if ( inPoly && m_TestType() == vsp::OUTSIDE )
{
return false;
}
}
if ( m_TestType() == vsp::OUTSIDE )
{
return true;
}
return false;
}
示例2: proj
//to return projection vector
vec3d vec3d :: proj(const vec3d& vec) const
{
float m = vec.mag();
if(m == 0)
throw "invalid vector";
return vec.unit()*(operator*(vec)/m);
}
示例3: UWtoTargetMapij
void Surf::ApplyES( vec3d uw, double t )
{
double grm1 = m_GridDensityPtr->m_GrowRatio() - 1.0;
int nmapu = m_SrcMap.size();
int nmapw = m_SrcMap[0].size();
int ibase, jbase;
double u = uw.x();
double w = uw.y();
UWtoTargetMapij( u, w, ibase, jbase );
vec3d p = m_SurfCore.CompPnt( u, w );
int iadd[] = { 0, 1, 0, 1 };
int jadd[] = { 0, 0, 1, 1 };
for( int i = 0; i < 4; i++ )
{
int itarget = ibase + iadd[i];
int jtarget = jbase + jadd[i];
if( itarget < nmapu && itarget >= 0 && jtarget < nmapw && jtarget >= 0 )
{
vec3d p2 = m_SrcMap[ itarget ][ jtarget ].m_pt;
double r = ( p2 - p ).mag();
double targetstr = t + r * grm1;
if( m_SrcMap[ itarget ][ jtarget ].m_str > targetstr )
{
m_SrcMap[ itarget ][ jtarget ].m_str = targetstr;
WalkMap( itarget, jtarget, itarget, jtarget );
}
}
}
}
示例4: vec3d
vec3d SSLineSeg::CompPnt( VspSurf* surf, vec3d uw_pnt ) const
{
if ( !surf )
{
return vec3d();
}
double maxu = surf->GetUMax();
double maxw = surf->GetWMax();
if ( uw_pnt.x() < 0.0 )
{
uw_pnt.set_x( 0.0 );
}
else if ( uw_pnt.x() > maxu )
{
uw_pnt.set_x( maxu );
}
if ( uw_pnt.y() < 0.0 )
{
uw_pnt.set_y( 0.0 );
}
else if ( uw_pnt.y() > maxw )
{
uw_pnt.set_y( maxw );
}
return surf->CompPnt( uw_pnt.x(), uw_pnt.y() );
}
示例5: Reflect
void VspCurve::Reflect( vec3d axis, double d )
{
curve_point_type a;
a << axis.x(), axis.y(), axis.z();
m_Curve.reflect( a, d );
}
示例6: Offset
//===== Offset =====//
void VspCurve::Offset( vec3d offvec )
{
curve_point_type tr;
tr << offvec.x(), offvec.y(), offvec.z();
m_Curve.translate( tr );
}
示例7: slerp
// Spherical linear interpolation between direction vectors.
// Intermediate vectors follow great circle path with constant velocity.
vec3d slerp( const vec3d& a, const vec3d& b, const double &t )
{
vec3d an = a / a.mag();
vec3d bn = b / b.mag();
double dp = dot( an, bn );
double theta = 0.0;
if ( dp >= -1.0 && dp <= 1.0 )
{
theta = acos( dp );
}
// Initialize retvec as a-direction.
vec3d retvec = an;
// If vectors are not parallel, interpolate between them.
if ( std::abs( theta ) > 1.0e-6 )
{
// Drop division by sin(theta) because .normalize() will scale
double coeff1 = sin( ( 1.0 - t ) * theta ); // implied / sin(theta)
double coeff2 = sin( t * theta ); // implied / sin(theta)
retvec = coeff1 * an + coeff2 * bn;
retvec.normalize();
}
return retvec;
}
示例8: ComputeID
//////////////////////////////////////////////////////////////////////
//==== IPnt Bin ====//
//////////////////////////////////////////////////////////////////////
int IPntBin::ComputeID( vec3d & pos )
{
int id = (int)(pos.x()*10000.0) +
(int)(pos.y()*10000.0) +
(int)(pos.z()*10000.0);
return id;
}
示例9: angle
//******* Angle Between Vectors ******//
double angle(const vec3d& a, const vec3d& b)
{
double angle = dot(a, b)/(a.mag()*b.mag());
if ( angle < -1.0 ) angle = -1.0;
else if ( angle > 1.0 ) angle = 1.0;
return(acos(angle));
}
示例10: vec_angle
static FLOAT64 vec_angle( vec3d v1, vec3d v2 ) {
FLOAT64 len1 = v1.len();
FLOAT64 len2 = v2.len();
FLOAT64 dot = len1 * len2;
if( dot ) {
FLOAT64 res = acos(fmin(1.0-1e-8,fmax(-1.0+1e-8,v1*v2/dot)));
return res;
}
return 0.0;
}
示例11: FindNearest
double VspCurve::FindNearest( double &u, const vec3d &pt, const double &u0 ) const
{
double dist;
curve_point_type p;
p << pt.x(), pt.y(), pt.z();
dist = eli::geom::intersect::minimum_distance( u, m_Curve, p, u0 );
return dist;
}
示例12: cos_angle
//******* Cosine of Angle Between Vectors ******//
double cos_angle(const vec3d& a, const vec3d& b)
{
double angle = dot(a, b)/(a.mag()*b.mag());
if (angle < -1.0 )
return -1.0;
else if ( angle > 1.0)
return 1.0;
return angle;
}
示例13: move
void PlanetViewController::move(vec3d &oldp, vec3d &p)
{
oldp = oldp.normalize();
p = p.normalize();
double oldlat = safe_asin(oldp.z);
double oldlon = atan2(oldp.y, oldp.x);
double lat = safe_asin(p.z);
double lon = atan2(p.y, p.x);
x0 -= lon - oldlon;
y0 -= lat - oldlat;
y0 = max(-M_PI / 2.0, min(M_PI / 2.0, y0));
}
示例14: angle
//******* Angle Between Vectors ******//
double angle( const vec3d& a, const vec3d& b )
{
double angle = dot( a, b ) / ( a.mag() * b.mag() );
if ( angle >= -1.0 && angle <= 1.0 )
{
return( acos( angle ) );
}
else
{
return( 0.0 );
}
}
示例15: planeByPointNormal
vec4d planeByPointNormal(vec3d point, vec3d normal) {
vec4d ret;
for (int i = 0; i < 3; i++)
ret.v[i] = normal.v[i];
ret.v[3] = -point.dot(normal);
return ret;
}