proj home

Files   Classes   Functions   Hierarchy  

Public Member Functions | Public Attributes | List of all members
gobjMyCircle Class Reference

Sampled circle or ellipse. More...

#include <graphmisc.h>

Inheritance diagram for gobjMyCircle:
Inheritance graph
Collaboration diagram for gobjMyCircle:
Collaboration graph

Public Member Functions

 gobjMyCircle (doublec theta0, doublec theta1, doublec xaxislength, doublec yaxislength, uintc N_=360)
 General arcs can be created by changing the angle interval [theta0,theta1].
 gobjMyCircle (doublec theta0, doublec theta1, doublec radius=1.0, uintc N_=360)
 Create an arc.
 gobjMyCircle (uintc N_=360)
 Create a circle.
void draw ()
 Dummy so that it can be placed on a gobj stack.
 ~gobjMyCircle ()
 Cleanup.
- Public Member Functions inherited from gobj
virtual ~gobj ()
 Destructor.

Public Attributes

uintc N
 The number of sampled points.
float *const ptx
 The samples x values.
float *const pty
 The samples y values.

Additional Inherited Members

- Static Public Member Functions inherited from gobj
static void globaldisplaylist (uintc id)
 Convert the global graphics into a display list.
- Static Public Attributes inherited from gobj
static gobjContainerglobal = 0
 The graphics stream.

Detailed Description

Sampled circle or ellipse.

This can be used in drawing circles of different sizes by gobjMyCircleDraw .

Definition at line 645 of file graphmisc.h.

Constructor & Destructor Documentation

gobjMyCircle::gobjMyCircle ( doublec  theta0,
doublec  theta1,
doublec  xaxislength,
doublec  yaxislength,
uintc  N_ = 360 
)

General arcs can be created by changing the angle interval [theta0,theta1].

Ellipses can be made by changing the axis lengths.

Definition at line 268 of file graphmisc.cpp.

: N(_N), ptx(new float[N]),
pty(new float[N])
{
//Just plot the curve
assert(theta1>theta0);
float t=theta0;
float dt=(theta1-theta0)/(N-1);
for (uint i=0; i<N; ++i)
{
ptx[i] = cos(t)*xaxislength;
pty[i] = sin(t)*yaxislength;
t += dt;
}
}
gobjMyCircle::gobjMyCircle ( doublec  theta0,
doublec  theta1,
doublec  radius = 1.0,
uintc  N_ = 360 
)

Create an arc.

Definition at line 293 of file graphmisc.cpp.

: N(_N), ptx(new float[N]),
pty(new float[N])
{
assert(radius>0.0);
float t=theta0;
float thetadiff = theta1-theta0;
if (thetadiff<0.0)
thetadiff += PI*2.0;
float dt=thetadiff/(N-1);
/*
cout << SHOW(theta1-theta0) << " " << SHOW(thetadiff);
cout << " " << SHOW(dt) << endl;
*/
/*
if (dt<0.0)
dt += 2.0*PI;
*/
for (uint i=0; i<N; ++i)
{
ptx[i] = cos(t)*radius;
pty[i] = sin(t)*radius;
t += dt;
}
/*
cout << SHOW(theta1-theta0) << " " << SHOW(dt) << endl;
cout << SHOW(theta0) << " " << SHOW(theta1) << endl;
cout << SHOW(cos(theta0)) << " " << SHOW(sin(theta0)) << endl;
cout << SHOW(radius) << endl;
cout << "start: (" << ptx[0] << "," << pty[0] << ")" << endl;
cout << "end: (" << ptx[N-1] << "," << pty[N-1] << ")" << endl;
*/
}
gobjMyCircle::gobjMyCircle ( uintc  N_ = 360)

Create a circle.

Definition at line 339 of file graphmisc.cpp.

: N(_N), ptx(new float[N]),
pty(new float[N])
{
float t=0.0;
float dt=2.0*PI/(N-1);
for (uint i=0; i<N; ++i)
{
ptx[i] = cos(t);
pty[i] = sin(t);
t += dt;
}
}
gobjMyCircle::~gobjMyCircle ( )

Cleanup.

Definition at line 357 of file graphmisc.cpp.

References ptx, and pty.

{
delete[] ptx;
delete[] pty;
}

Member Function Documentation

void gobjMyCircle::draw ( )
inlinevirtual

Dummy so that it can be placed on a gobj stack.

Implements gobj.

Definition at line 683 of file graphmisc.h.

References GOBJDEBUGCODE.

Member Data Documentation

uintc gobjMyCircle::N

The number of sampled points.

Definition at line 650 of file graphmisc.h.

Referenced by gobjMyCircleDraw::draw().

float* const gobjMyCircle::ptx

The samples x values.

Definition at line 653 of file graphmisc.h.

Referenced by gobjMyCircleDraw::draw(), and ~gobjMyCircle().

float* const gobjMyCircle::pty

The samples y values.

Definition at line 655 of file graphmisc.h.

Referenced by gobjMyCircleDraw::draw(), and ~gobjMyCircle().


The documentation for this class was generated from the following files: