本文整理汇总了C++中ON_3dVector::MaximumCoordinateIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ ON_3dVector::MaximumCoordinateIndex方法的具体用法?C++ ON_3dVector::MaximumCoordinateIndex怎么用?C++ ON_3dVector::MaximumCoordinateIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ON_3dVector
的用法示例。
在下文中一共展示了ON_3dVector::MaximumCoordinateIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PerpindicularDirection
ON_3dVector ON_Light::PerpindicularDirection() const
{
// returns a consistent vector perpendicular to the
// light's direction. This vector is useful for
// user interface display.
ON_3dVector dir = m_direction;
if ( !dir.IsValid() || !dir.Unitize() )
return ON_UNSET_VECTOR;
ON_3dVector xdir;
if ( IsLinearLight() || IsRectangularLight() )
{
xdir = m_length;
if ( xdir.IsValid() && xdir.Unitize() && fabs(xdir*dir) <= ON_SQRT_EPSILON )
return xdir;
}
if( dir.IsParallelTo( ON_zaxis, ON_DEGREES_TO_RADIANS * 3.0))
xdir = ON_CrossProduct( dir, ON_xaxis);
else
xdir = ON_CrossProduct( dir, ON_zaxis);
xdir.Unitize();
ON_3dVector ydir = ON_CrossProduct(dir,xdir);
ydir.Unitize();
ON_3dVector right;
switch(dir.MaximumCoordinateIndex())
{
case 0:
right = (fabs(xdir.y) > fabs(ydir.y)) ? xdir : ydir;
if ( right.y < 0.0 )
right.Reverse();
break;
case 1:
case 2:
right = (fabs(xdir.x) > fabs(ydir.x)) ? xdir : ydir;
if ( right.x < 0.0 )
right.Reverse();
break;
default:
right = xdir;
break;
}
if ( right[right.MaximumCoordinateIndex()] < 0.0 )
right.Reverse();
return right;
}
示例2: ON_Intersect
bool ON_Intersect( const ON_BoundingBox& bbox,
const ON_Line& line,
double tol,
ON_Interval* line_parameters)
{
double a,b,d,mn,mx,s0,s1, t0, t1;
const double M = 1.0e308;
// i,j,k are indices of coordinates to trim.
// trim the direction with the biggest line deltas first
ON_3dVector v = line.Direction();
const int i = v.MaximumCoordinateIndex();
// gaurd against ON_UNSET_VALUE as input
if ( !(tol >= 0.0) )
tol = 0.0;
// clip i-th coordinate
a = line.from[i];
b = line.to[i];
mn = bbox.m_min[i];
mx = bbox.m_max[i];
if ( !(mn <= mx) )
return false;
mn -= (tol+a);
mx += (tol-a);
if ( !(mn <= mx) )
return false;
d = b-a;
if ( 0.0 == d )
{
// happens when line.from == line.to
if ( 0.0 < mn || 0.0 > mx )
{
// point is in box
if ( line_parameters )
{
// setting parameters makes no sense - just use 0.0
// so it's clear we have a point
line_parameters->Set(0.0,0.0);
}
return true;
}
return false; // point is outside box
}
if ( fabs(d) < 1.0 && (fabs(mn) >= fabs(d)*M || fabs(mx) >= fabs(d)*M) )
{
// the value of mn/d or mx/d is too large for a realistic answer to be computed
return false;
}
d = 1.0/d;
t0 = mn*d;
t1 = mx*d;
// set "chord" = line segment that begins and ends on the
// i-th coordinate box side planes.
ON_Line chord(line.PointAt(t0),line.PointAt(t1));
// test j-th coordinate direction
const int j = (i + (fabs(v[(i+1)%3])>fabs(v[(i+2)%3])?1:2) ) % 3;
a = chord.from[j];
b = chord.to[j];
mn = bbox.m_min[j];
mx = bbox.m_max[j];
if ( !(mn <= mx) )
return false;
mn -= (tol+a);
mx += (tol-a);
if ( !(mn <= mx) )
return false;
d = b-a;
if ( (0.0 < mn && d < mn) || (0.0 > mx && d > mx) )
{
// chord lies outside the box
return false;
}
while ( fabs(d) >= 1.0 || (fabs(mn) <= fabs(d)*M && fabs(mx) <= fabs(d)*M) )
{
// The chord is not (nearly) parallel to the j-th sides.
// See if the chord needs to be trimmed by the j-th sides.
d = 1.0/d;
s0 = mn*d;
s1 = mx*d;
if ( s0 > 1.0 )
{
if ( s1 > 1.0 )
{
// unstable calculation happens when
// fabs(d) is very tiny and chord is
// on the j-th side.
break;
}
s0 = 1.0;
}
else if ( s0 < 0.0 )
{
if (s1 < 0.0)
{
// unstable calculation happens when
//.........这里部分代码省略.........