Click here to Skip to main content
15,895,423 members
Articles / Desktop Programming / MFC

Basic Curves And Surfaces Modeler

Rate me:
Please Sign up or sign in to vote.
4.17/5 (40 votes)
18 Apr 2012CPOL3 min read 248.5K   16.4K   117  
A basic demo of modeling curves and surfaces in OpenGL.
// Helix.cpp: implementation of the CHelix class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"

#include "Helix.h"

#include "Point3D.h"
#include "Vector3D.h"


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

CHelix::CHelix(const CAxisSystem& Ax, const double& radius, const double& start, const double& end, const double lead) : itsLead(lead)
{
	itsLocation = Ax;
	itsRadius = radius;
	itsFirstParameter = start;
	itsLastParameter = end;
}

CHelix::~CHelix()
{

}

void CHelix::Reverse()
{
}

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

	double c = cos(para);
	double s = sin(para);
	double v = ((para-itsFirstParameter)/(PI*2))*itsLead;
	V = itsLocation.GetOrigin()+(itsLocation.GetXDirection()*c+itsLocation.GetYDirection()*s)
			*GetRadius()+itsLocation.GetDirection()*v;
	P.SetParam(V.GetX(), V.GetY(), V.GetZ());

	return P;
}

double CHelix::FirstParameter() const
{
	return itsFirstParameter;
}

double CHelix::LastParameter() const
{
	return itsLastParameter;
}

bool CHelix::IsClosed() const
{
	return false;
}

CurveType CHelix::Type() const
{
	return HELIX;
}

bool CHelix::IsOfType(const CurveType& theType) const
{
	bool b = (theType == HELIX);
	return b;
}

CCurve* CHelix::Copy() const
{
	CHelix* H = new CHelix(itsLocation, itsRadius, itsFirstParameter, itsLastParameter, itsLead);
	return H;
}

void CHelix::Translate(double dx, double dy, double dz)
{
}

void CHelix::Translate(const CVector3D&)
{
}

void CHelix::Translate(const CPoint3D&, const CPoint3D&)
{
}

void CHelix::Rotate(const COneAxis&, double)
{
}

void CHelix::Scale(const CPoint3D&, double)
{
}

void CHelix::Mirror(const CPoint3D&)
{
}

void CHelix::Mirror(const COneAxis&)
{
}

void CHelix::Mirror(const CPlane&)
{
}

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)


Written By
Product Manager Mahindra & Mahindra
India India
Sharjith is a Mechanical Engineer with strong passion for Automobiles, Aircrafts and Software development.

Comments and Discussions