资源简介
使用OpenGL编写的三维曲线和曲面,VC6环境,代码很规范,层次比较清晰,适合中级开发人员
代码片段和文件信息
// AxisSystem.cpp: implementation of the CAxisSystem class.
//
//////////////////////////////////////////////////////////////////////
#include “stdafx.h“
#include “CadSurf.h“
#include “Point3D.h“
#include “Vector3D.h“
#include “OneAxis.h“
#include “AxisSystem.h“
#include “GeomException.h“
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//Implementation of class CoordSys (Local Coordinate System)
CAxisSystem::CAxisSystem()
{
geomType = CAXISSYSTEM;
}
CAxisSystem::CAxisSystem(const CPoint3D& Pos const CVector3D& Dir const CVector3D& XDir)
{
Position = Pos;
Origin.SetParam(Pos.GetX()Pos.GetY()Pos.GetZ());
Direction = Dir;
Direction.Normalize();
XDirection = XDir;
XDirection.Normalize();
if(!Direction.IsNormal(XDirection))
throw CGeomException(ConstructionFailure);
else
YDirection = Direction.Crossed(XDirection);
geomType = CAXISSYSTEM;
}
CAxisSystem::CAxisSystem(const CPoint3D& Pos const CVector3D& Dir)
{
Position = Pos;
Origin.SetParam(Pos.GetX()Pos.GetY()Pos.GetZ());
Direction = Dir;
Direction.Normalize();
CVector3D V = Direction;
double lA = V.GetX();
double lB = V.GetY();
double lC = V.GetZ();
double Aabs = lA;
if (Aabs < 0)
Aabs = - Aabs;
double Babs = lB;
if (Babs < 0)
Babs = - Babs;
double Cabs = lC;
if (Cabs < 0)
Cabs = - Cabs;
CVector3D XAxis;
if ( Babs <= Aabs && Babs <= Cabs)
{
if (Aabs > Cabs)
XAxis.SetParam(-lC0. lA);
else
XAxis.SetParam( lC0.-lA);
}
else if( Aabs <= Babs && Aabs <= Cabs)
{
if (Babs > Cabs)
XAxis.SetParam(0.-lC lB);
else
XAxis.SetParam(0. lC-lB);
}
else
{
if (Aabs > Babs)
XAxis.SetParam(-lB lA0.);
else
XAxis.SetParam(lB-lA0.);
}
XDirection = XAxis;
XDirection.Normalize();
if(!Direction.IsNormal(XDirection))
throw CGeomException(ConstructionFailure);
else
YDirection = Direction.Crossed(XDirection);
geomType = CAXISSYSTEM;
}
CAxisSystem::CAxisSystem(const CAxisSystem& Ax)
{
Position = Ax.GetPosition();
Origin = Ax.GetOrigin();
Direction = Ax.GetDirection();
XDirection = Ax.GetXDirection();
YDirection = Direction.Crossed(XDirection);
geomType = CAXISSYSTEM;
}
CAxisSystem::~CAxisSystem()
{
}
void CAxisSystem::SetDirection(const CVector3D& D)
{
Direction = D;
Direction.Normalize();
if(!XDirection.IsParallel(Direction))
{
CVector3D tempY = D.Crossed(XDirection);
XDirection = tempY.Crossed(D);
YDirection = Direction.Crossed(XDirection);
XDirection.Normalize();
YDirection.Normalize();
}
else
{
CVector3D tempX = YDirection.Crossed(D);
YDirection = D.Crossed(tempX);
XDirection = Direction.Crossed(YDirection);
XDirection.Normalize(
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2003-02-22 21:18 CadSurf\
文件 7002 2003-02-07 12:56 CadSurf\AxisSystem.cpp
文件 2661 2003-02-05 10:24 CadSurf\AxisSystem.h
文件 574 2002-12-21 18:09 CadSurf\BasicSurface.cpp
文件 2226 2003-02-05 10:24 CadSurf\BasicSurface.h
文件 6808 2003-01-23 17:10 CadSurf\BezierCurve.cpp
文件 2123 2003-02-05 10:24 CadSurf\BezierCurve.h
文件 2139 2003-01-27 13:23 CadSurf\BoundingBox.cpp
文件 1954 2003-02-05 10:24 CadSurf\BoundingBox.h
文件 3110 2003-01-16 19:12 CadSurf\Bsp.cpp
文件 677 2003-01-16 19:41 CadSurf\Bsp.h
文件 7126 2003-01-23 17:10 CadSurf\BSplineCurve.cpp
文件 2111 2003-02-05 10:24 CadSurf\BSplineCurve.h
文件 545628 2003-02-22 18:39 CadSurf\CadSurf.aps
文件 7287 2003-02-05 23:01 CadSurf\CadSurf.cpp
文件 13683 2003-02-13 15:03 CadSurf\CadSurf.dsp
文件 539 2002-12-19 10:30 CadSurf\CadSurf.dsw
文件 2149 2003-02-05 10:38 CadSurf\CadSurf.h
文件 82944 2003-02-22 21:09 CadSurf\CadSurf.opt
文件 27824 2003-02-16 21:21 CadSurf\CadSurf.rc
文件 36756 2003-02-20 11:57 CadSurf\CadSurfDoc.cpp
文件 3738 2003-02-05 10:24 CadSurf\CadSurfDoc.h
文件 21456 2003-02-22 20:02 CadSurf\CadSurfView.cpp
文件 5533 2003-02-22 20:01 CadSurf\CadSurfView.h
文件 2366 2002-12-21 00:46 CadSurf\ChildFrm.cpp
文件 2072 2003-02-05 10:24 CadSurf\ChildFrm.h
文件 4488 2003-02-06 22:25 CadSurf\Circle3D.cpp
文件 2482 2003-02-05 10:24 CadSurf\Circle3D.h
文件 2798 2003-02-06 22:23 CadSurf\Cone.cpp
文件 2258 2003-02-05 10:24 CadSurf\Cone.h
文件 718 2002-12-29 16:26 CadSurf\Conic.cpp
............此处省略111个文件信息
- 上一篇:表达式求值C语言实现
- 下一篇:log4z-master
评论
共有 条评论