Click here to Skip to main content
11,631,896 members (70,258 online)
Click here to Skip to main content
Articles » Multimedia » OpenGL » General » Downloads
Add your own
alternative version

Basic Curves And Surfaces Modeler

, 18 Apr 2012 CPOL 180.9K 14K 114
A basic demo of modeling curves and surfaces in OpenGL.
cadsurfexe.zip
CadSurfexe
CadSurf.exe
VKGeom.dll
VKGraphic.dll
cadsurf_demo.zip
CadSurf.exe
cadsurf_src.zip
CadSurf_src
VKernel
VKGraphic
VKGraphic.dsp
VKGraphic.dsw
VKGraphic.plg
VKGeom
VKGeom.dsp
VKGeom.dsw
cadsurf
CadSurf.clw
CadSurf.dsp
cadsurf.dsw
Thumbs.db
res
bmp00001.bmp
cadsurf.ico
CADSURFDOC.ICO
new_splash.bmp
new_splash.PNG
new_splash_small.bmp
tb_geom.bmp
Thumbs.db
toolbar.bmp
toolbar1.bmp
untitled.bmp
XPStyle.manifest
CadSurf_VS2008.zip
CadSurf
cadsurf
CadSurf.suo
res
bmp00001.bmp
cadsurf.ico
CADSURFDOC.ICO
new_splash.bmp
new_splash.PNG
new_splash_small.bmp
tb_geom.bmp
Thumbs.db
toolbar.bmp
toolbar1.bmp
untitled.bmp
VKernel
VKGeom
VKGraphic
VKGraphic.plg
// Ellipse3D.cpp: implementation of the CEllipse3D class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"

#include "Ellipse3D.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CEllipse3D::CEllipse3D()
{
	cType = ELLIPSE;
}

CEllipse3D::CEllipse3D(const CPoint3D& cp, const double min, const double maj) : minorRadius(min)
, majorRadius(maj)
{
	CAxisSystem ax(cp, CVector3D(0,0,1), CVector3D(1,0,0));
	itsLocation = ax;
	cType = ELLIPSE;
}

CEllipse3D::CEllipse3D(const CAxisSystem& Ax, double min, double maj) : minorRadius(min), majorRadius(maj)
{
	itsLocation = Ax;
	cType = ELLIPSE;
}

CEllipse3D::~CEllipse3D()
{
}

void CEllipse3D::Reverse()
{
	cReversed = !cReversed;
}

CEllipse3D CEllipse3D::Reversed() const
{
	CEllipse3D E = (*this);
	E.Reverse();
	return E;
}

double CEllipse3D::Eccentricity() const
{
	if(majorRadius == 0.0)
		return 0.0;
	else
		return sqrt(majorRadius * majorRadius - 
		minorRadius * minorRadius) / majorRadius;
}

CPoint3D CEllipse3D::PointAtPara(const double& Par)
{
	CVector3D V;
	double para = Par;

	if(cReversed)
		para = 2*PI - para;

	double c = cos(para);
	double s = sin(para);
	V = itsLocation.GetOrigin() + itsLocation.GetXDirection()*majorRadius*c
		+ itsLocation.GetYDirection()*minorRadius*s;

	return V.Point();
}

bool CEllipse3D::IsClosed() const
{
	return true;
}

bool CEllipse3D::operator == (const CEllipse3D& E) const
{
	bool eq = (itsLocation == E.GetLocation() && majorRadius == E.GetMajorRadius()
				&& minorRadius == E.GetMinorRadius());
	return eq;
}

void CEllipse3D::operator = (const CEllipse3D& E)
{
	itsLocation = E.GetLocation();
	majorRadius = E.GetMajorRadius();
	minorRadius = E.GetMinorRadius();
}

CCurve* CEllipse3D::Copy() const
{
	CEllipse3D* E = new CEllipse3D(itsLocation, majorRadius, minorRadius);
	return E;
}

void CEllipse3D::Translate(const COneAxis& Ax, const double& amt)
{
	CGeometry::Translate(Ax, amt);
}

void CEllipse3D::Translate(double dx, double dy, double dz)
{
	itsLocation.Translate(dx,dy,dz);
}

void CEllipse3D::Translate(const CVector3D& V)
{
	itsLocation.Translate(V);
}

void CEllipse3D::Translate(const CPoint3D& P1, const CPoint3D& P2)
{
	itsLocation.Translate(P1, P2);
}

void CEllipse3D::Rotate(const COneAxis& Ax, double fact)
{
	itsLocation.Rotate(Ax, fact);
}

void CEllipse3D::Scale(const CPoint3D& P, double fact)
{
	itsLocation.Scale(P, fact);
	majorRadius *= fact;
	minorRadius *= fact;
	if(majorRadius < 0)
		majorRadius = -majorRadius;
	if(minorRadius < 0)
		minorRadius = -minorRadius;
}

void CEllipse3D::Mirror(const CPoint3D& P)
{
	itsLocation.Mirror(P);
}

void CEllipse3D::Mirror(const COneAxis& Ax)
{
	itsLocation.Mirror(Ax);
}

void CEllipse3D::Mirror(const CPlane& Pln)
{
	itsLocation.Mirror(Pln);
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Sharjith
Engineer Tata Technologies Ltd
India India
Sharjith is a Mechanical Engineer with strong passion for Automobiles, Aircrafts and Software development.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150728.1 | Last Updated 18 Apr 2012
Article Copyright 2003 by Sharjith
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid