本文整理汇总了C++中ON_Xform类的典型用法代码示例。如果您正苦于以下问题:C++ ON_Xform类的具体用法?C++ ON_Xform怎么用?C++ ON_Xform使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ON_Xform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ON_GL
void ON_GL( ON_Viewport& viewport,
int port_left, int port_right,
int port_bottom, int port_top
)
{
// Sets viewport's port to port_* values and adjusts frustum
// so it's aspect matches the port's.
ON_Xform projectionMatrix; // camera to clip transformation
const int port_width = abs(port_right - port_left);
const int port_height = abs(port_top - port_bottom);
if ( port_width == 0 || port_height == 0 )
return;
const double port_aspect = ((double)port_width)/((double)port_height);
viewport.SetFrustumAspect( port_aspect );
viewport.SetScreenPort( port_left, port_right, port_bottom, port_top,
0, 0xff );
ON_BOOL32 bHaveCameraToClip = viewport.GetXform(
ON::camera_cs,
ON::clip_cs,
projectionMatrix
);
if ( bHaveCameraToClip ) {
projectionMatrix.Transpose();
glMatrixMode(GL_PROJECTION);
glLoadMatrixd( &projectionMatrix.m_xform[0][0] );
}
}
示例2: CalculateTransform
BOOL COrientOnCrvXform::CalculateTransform( CRhinoViewport& vp, const ON_3dPoint& pt, ON_Xform& xform )
{
BOOL bResult = FALSE;
if( m_path_curve )
{
double t = 0.0;
if( m_path_curve->GetClosestPoint(pt, &t) )
{
ON_3dPoint origin = m_path_curve->PointAt( t );
ON_Plane dest_plane;
if( m_perp_mode )
{
ON_3dVector tangent = m_path_curve->TangentAt( t );
MakeNormalPlane( origin, tangent, dest_plane );
}
else
{
dest_plane.origin = origin;
dest_plane.xaxis = m_path_curve->TangentAt( t );
dest_plane.zaxis = m_base_plane.zaxis;
dest_plane.yaxis = ON_CrossProduct( dest_plane.zaxis, dest_plane.xaxis );
dest_plane.UpdateEquation();
}
xform.Rotation( m_base_plane, dest_plane );
bResult = xform.IsValid() ? TRUE : FALSE;
}
}
return bResult;
}
示例3: Scale
ON_BOOL32 ON_Geometry::Scale( double x )
{
if ( x == 1.0 )
return true;
ON_Xform s;
s.Scale( x, x, x );
return Transform( s );
}
示例4: Translate
ON_BOOL32 ON_Geometry::Translate( const ON_3dVector& delta )
{
if ( delta.IsZero() )
return true;
ON_Xform tr;
tr.Translation( delta );
return Transform( tr );
}
示例5: Translate
bool ON_Plane::Translate(
const ON_3dVector& delta
)
{
ON_Xform tr;
tr.Translation( delta );
return Transform( tr );
}
示例6: sin
bool ON_BezierCage::Rotate(
double sin_angle, // sin(angle)
double cos_angle, // cos(angle)
const ON_3dVector& axis, // axis of rotation
const ON_3dPoint& center // center of rotation
)
{
ON_Xform rot;
rot.Rotation( sin_angle, cos_angle, axis, center );
return Transform( rot );
}
示例7: GetRotation
bool ON_Quaternion::GetRotation(ON_Xform& xform) const
{
ON_Plane plane;
bool rc = GetRotation(plane);
if (rc)
xform.Rotation(ON_Plane::World_xy,plane);
else if (IsZero())
xform.Zero();
else
xform.Identity();
return rc;
}
示例8: q
bool ON_Quaternion::GetRotation(ON_Xform& xform) const
{
bool rc;
ON_Quaternion q(*this);
if ( q.Unitize() )
{
if ( fabs(q.a-a) <= ON_ZERO_TOLERANCE
&& fabs(q.b-b) <= ON_ZERO_TOLERANCE
&& fabs(q.c-c) <= ON_ZERO_TOLERANCE
&& fabs(q.d-d) <= ON_ZERO_TOLERANCE
)
{
// "this" was already unitized - don't tweak bits
q = *this;
}
xform[1][0] = 2.0*(q.b*q.c + q.a*q.d);
xform[2][0] = 2.0*(q.b*q.d - q.a*q.c);
xform[3][0] = 0.0;
xform[0][1] = 2.0*(q.b*q.c - q.a*q.d);
xform[2][1] = 2.0*(q.c*q.d + q.a*q.b);
xform[3][1] = 0.0;
xform[0][2] = 2.0*(q.b*q.d + q.a*q.c);
xform[1][2] = 2.0*(q.c*q.d - q.a*q.b);
xform[3][2] = 0.0;
q.b = q.b*q.b;
q.c = q.c*q.c;
q.d = q.d*q.d;
xform[0][0] = 1.0 - 2.0*(q.c + q.d);
xform[1][1] = 1.0 - 2.0*(q.b + q.d);
xform[2][2] = 1.0 - 2.0*(q.b + q.c);
xform[0][3] = xform[1][3] = xform[2][3] = 0.0;
xform[3][3] = 1.0;
rc = true;
}
else if ( IsZero() )
{
xform.Zero();
rc = false;
}
else
{
// something is seriously wrong
ON_ERROR("ON_Quaternion::GetRotation(ON_Xform) quaternion is invalid");
xform.Identity();
rc = false;
}
return rc;
}
示例9: sin
ON_BOOL32 ON_Geometry::Rotate(
double sin_angle, // sin(angle)
double cos_angle, // cos(angle)
const ON_3dVector& axis, // axis of rotation
const ON_3dPoint& center // center of rotation
)
{
if ( sin_angle == 0.0 && cos_angle == 1.0 )
return true;
ON_Xform rot;
rot.Rotation( sin_angle, cos_angle, axis, center );
return Transform( rot );
}
示例10: tmp
BOOL ON_Hatch::Transform( const ON_Xform& xform)
{
if( fabs( fabs( xform.Determinant()) - 1.0) > 1.0e-4)
{
// xform has a scale component
ON_Plane tmp( m_plane);
tmp.Transform( xform);
ON_Xform A, B, T;
A.Rotation( ON_xy_plane, m_plane);
B.Rotation( tmp, ON_xy_plane);
T = B * xform * A;
// kill translation and z-scaling
T[0][2] = T[0][3] = 0.0;
T[1][2] = T[1][3] = 0.0;
T[2][0] = T[2][1] = 0.0; T[2][2] = 1.0; T[2][3] = 0.0;
T[3][0] = T[3][1] = T[3][2] = 0.0; T[3][3] = 1.0;
for( int i = 0; i < LoopCount(); i++)
m_loops[i]->m_p2dCurve->Transform( T);
}
int rc = m_plane.Transform( xform);
return rc;
}
示例11: TransformUserData
ON_BOOL32
ON_PlaneSurface::Transform( const ON_Xform& xform )
{
TransformUserData(xform);
ON_3dPoint p = m_plane.origin + m_extents[0][0]*m_plane.xaxis + m_extents[1][0]*m_plane.yaxis;
ON_3dPoint q = m_plane.origin + m_extents[0][1]*m_plane.xaxis + m_extents[1][1]*m_plane.yaxis;
bool rc = m_plane.Transform( xform )?true:false;
if (rc && fabs(fabs(xform.Determinant())-1.0) > ON_SQRT_EPSILON )
{
p = xform*p;
q = xform*q;
double x0, x1, y0, y1;
rc = false;
if ( m_plane.ClosestPointTo(p,&x0,&y0) && m_plane.ClosestPointTo(q,&x1,&y1) )
{
if ( x0 < x1 && y0 < y1 )
{
m_extents[0].Set(x0,x1);
m_extents[1].Set(y0,y1);
rc = true;
}
}
}
return rc;
}
示例12: sin
// rotate line about a point and axis
bool ON_Line::Rotate(
double sin_angle, // sin(angle)
double cos_angle, // cos(angle)
const ON_3dVector& axis, // axis of rotation
const ON_3dPoint& center // center of rotation
)
{
ON_Xform rot;
rot.Rotation( sin_angle, cos_angle, axis, center );
const bool bFixP0 = (from==center);
const bool bFixP1 = (to==center);
const bool rc = Transform( rot );
if ( bFixP0 )
from = center;
if ( bFixP1 )
to = center;
return rc;
}
示例13: IsValid
ON_BOOL32 ON_InstanceRef::IsValid( ON_TextLog* text_log ) const
{
if ( 0 == ON_UuidCompare( m_instance_definition_uuid, ON_nil_uuid) )
{
if ( text_log )
text_log->Print("ON_InstanceRef has nil m_instance_definition_uuid.\n");
return false;
}
ON_Xform tmp = m_xform.Inverse()*m_xform;
if ( !tmp.IsIdentity( ON_InstanceRef::m_singular_xform_tol ) )
{
if ( text_log )
text_log->Print("ON_InstanceRef has singular m_xform.\n");
return false;
}
return true;
}
示例14: Mat4Dto4F
void CRhGLShaderProgram::SetupViewport(const ON_Viewport& vp)
{
ON_Xform mv;
bool bHaveModeView = false;
if ( m_Uniforms.rglModelViewProjectionMatrix >= 0 )
{
float ModelViewProjection[16];
ON_Xform mvp;
vp.GetXform( ON::world_cs, ON::clip_cs, mvp );
mvp.Transpose();
Mat4Dto4F( &mvp.m_xform[0][0], ModelViewProjection );
glUniformMatrix4fv( m_Uniforms.rglModelViewProjectionMatrix, 1, GL_FALSE, ModelViewProjection );
}
if ( m_Uniforms.rglModelViewMatrix >= 0 )
{
float ModelView[16];
vp.GetXform( ON::world_cs, ON::camera_cs, mv );
mv.Transpose();
bHaveModeView = true;
Mat4Dto4F( &mv.m_xform[0][0], ModelView );
glUniformMatrix4fv( m_Uniforms.rglModelViewMatrix, 1, GL_FALSE, ModelView );
}
if ( m_Uniforms.rglProjectionMatrix >= 0 )
{
float Projection[16];
ON_Xform pr;
vp.GetXform( ON::camera_cs, ON::clip_cs, pr );
pr.Transpose();
Mat4Dto4F( &pr.m_xform[0][0], Projection );
glUniformMatrix4fv( m_Uniforms.rglProjectionMatrix, 1, GL_FALSE, Projection );
}
if ( m_Uniforms.rglNormalMatrix >= 0 )
{
float NormalMatrix[9];
if ( !bHaveModeView )
{
vp.GetXform( ON::world_cs, ON::camera_cs, mv );
mv.Transpose();
bHaveModeView = true;
}
Mat4Dto3F( &mv.m_xform[0][0], NormalMatrix );
glUniformMatrix3fv( m_Uniforms.rglNormalMatrix, 1, GL_FALSE, NormalMatrix );
}
}
示例15: Transform
bool ON_3dPointArray::Rotate(
double sin_angle,
double cos_angle,
const ON_3dVector& axis_of_rotation,
const ON_3dPoint& center_of_rotation
)
{
const int count = m_count;
ON_Xform rot;
rot.Rotation( sin_angle, cos_angle, axis_of_rotation, center_of_rotation );
ON_SimpleArray<int> fix_index(128);
int i;
for ( i = 0; i < count; i++ ) {
if ( m_a[i] == center_of_rotation )
fix_index.Append(i);
}
const bool rc = Transform( rot );
for ( i = 0; i < fix_index.Count(); i++ ) {
m_a[fix_index[i]] = center_of_rotation;
}
return rc;
}