Click here to Skip to main content
Click here to Skip to main content
Articles » Multimedia » OpenGL » General » Downloads
 
Add your own
alternative version
Go to top

Basic Curves And Surfaces Modeler

, 18 Apr 2012
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
// OneAxis2D.cpp: implementation of the COneAxis2D class.
//
//////////////////////////////////////////////////////////////////////


#include "stdafx.h"

#include "OneAxis2D.h"
#include "Point2D.h"
#include "Vector2D.h"
#include "MMath.h"

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

//Implementation of class OneAxis 
//(Used for construction of revolutions and as axis of symmetries)
COneAxis2D::COneAxis2D()
{
	Position = CPoint2D(0,0);
	Direction = CVector2D(1,0);
	Direction.Normalize();
	Origin.SetParam(0,0);
	geomType = CONEAXIS2D;
}

COneAxis2D::COneAxis2D(const CPoint2D& Pos, const CVector2D& Dir) : Position(Pos), Direction(Dir)
{
	Direction.Normalize();
	Origin.SetParam(Pos.GetX(),Pos.GetY());
	geomType = CONEAXIS2D;
}

COneAxis2D::~COneAxis2D()
{
}

void COneAxis2D::SetPosition(const CPoint2D& P)
{
	Position = P;
	Origin = P;
}

void COneAxis2D::SetPosition(double x, double y)

{
	Position.SetParam(x,y);
	Origin.SetParam(x,y);
}

void COneAxis2D::SetDirection(const CVector2D& D)
{
	Direction = D;
	Direction.Normalize();
}

void COneAxis2D::SetDirection(double dx, double dy)
{
	Direction.SetParam(dx,dy);
	Direction.Normalize();
}

CPoint2D COneAxis2D::GetPosition() const
{
	return Position;
}

CVector2D COneAxis2D::GetOrigin() const
{
	return Origin;
}

CVector2D COneAxis2D::GetDirection() const
{
	return Direction;
}

bool COneAxis2D::operator == (const COneAxis2D& rhAx) const
{
	bool eq = (Position == rhAx.GetPosition() && Direction == rhAx.GetDirection()
				&& Origin == rhAx.GetOrigin());
	return eq;
}

void COneAxis2D::Translate(const COneAxis2D& Ax, const double& amt)
{
	CGeometry2D::Translate(Ax, amt);
}

void COneAxis2D::Translate(double dx, double dy)
{
	CPoint2D P = Position;
	P.Translate(dx, dy);
	SetPosition(P);
	Origin.SetParam(P.GetX(), P.GetY());
}

void COneAxis2D::Translate(const CVector2D& V)
{
	CPoint2D P = Position;
	P.Translate(V);
	SetPosition(P);
	Origin.SetParam(P.GetX(), P.GetY());
}

void COneAxis2D::Translate(const CPoint2D& P1, const CPoint2D& P2)
{
	CPoint2D P = Position;
	P.Translate(P1, P2);
	SetPosition(P);
	Origin.SetParam(P.GetX(), P.GetY());
}

void COneAxis2D::Rotate(const CPoint2D& Ax, double ang)
{
	CPoint2D P = Position;
	CVector2D D = Direction;
	P.Rotate(Ax, ang);
	D.Rotate(Ax, ang);
	SetPosition(P);
	SetDirection(D);
	Origin.SetParam(P.GetX(), P.GetY());
}

void COneAxis2D::Scale(const CPoint2D& Pnt, double fact)
{
	CPoint2D P = Position;
	CVector2D D = Direction;
	P.Scale(Pnt, fact);
	D.Scale(Pnt, fact);
	SetPosition(P);
	SetDirection(D);
	Origin.SetParam(P.GetX(), P.GetY());
}

void COneAxis2D::Mirror(const CPoint2D& Pnt)
{
	CPoint2D P = Position;
	CVector2D D = Direction;
	P.Mirror(Pnt);
	D.Mirror(Pnt);
	SetPosition(P);
	SetDirection(D);
	Origin.SetParam(P.GetX(), P.GetY());
}

void COneAxis2D::Mirror(const COneAxis2D& Ax)
{
	CPoint2D P = Position;
	CVector2D D = Direction;
	/*CString str;
	str.Format(" Now Direction X %0.3lf Y %0.3lf Z %0.3lf", D.GetX(),D.GetY(),D.GetZ());
	MessageBox(0, str, "From Axis", MB_OK);*/
	P.Mirror(Ax);
	CVector2D dir = Ax.GetDirection();
	if(dir.IsParallel(D))
		D.Mirror(Ax.GetDirection());
	else
		D.Mirror(Ax);
	/*str.Format(" Now Direction X %0.3lf Y %0.3lf Z %0.3lf", D.GetX(),D.GetY(),D.GetZ());
	MessageBox(0, str, "From Axis", MB_OK);*/
	SetPosition(P);
	SetDirection(D);
	Origin.SetParam(P.GetX(), P.GetY());
}

COneAxis2D COneAxis2D::OX()
{
	COneAxis2D Ax(CPoint2D(0,0), CVector2D(1,0));
	return Ax;
}

COneAxis2D COneAxis2D::OY()
{
	COneAxis2D Ax(CPoint2D(0,0), CVector2D(0,1));
	return Ax;
}

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.

| Advertise | Privacy | Mobile
Web04 | 2.8.141002.1 | Last Updated 18 Apr 2012
Article Copyright 2003 by Sharjith
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid