Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Examples  

QSProjection Class Reference

Base class for 2D,3D world -> screen transformations. More...

#include <qsprojection.h>

Inheritance diagram for QSProjection:

Inheritance graph
[legend]
List of all members.

Public Types

enum  ClipResult { Rejected = 0, Clipped, Accepted }

Public Methods

 QSProjection ()
virtual ~QSProjection ()
virtual void setLight (bool enabled)
virtual void setLightParameters (const QSPt3f &lightVector, int ambientLight, int directedLight)
bool light () const
QSPt3f lightVector () const
int ambientLight () const
int directedLight () const
virtual QSPt3f world2DToCanvas3 (const QSPt2f &p) const=0
virtual QSPt2f world2DToCanvas (const QSPt2f &p) const=0
virtual QSPt3f world3DToCanvas3 (const QSPt3f &p) const=0
virtual QSPt2f world3DToCanvas (const QSPt3f &p) const=0
virtual QSPt3f canvas3ToWorld3D (const QSPt3f &p) const=0
QSPt2f map (const QSPt3f &pos) const
QSPt3f map (const QSPt2f &pos) const
virtual QSPt3f furthest () const
virtual QSPt2f middle () const
virtual ClipResult clipPoint2 (const QSPt2f &p1) const
virtual ClipResult clipLine2 (QSPt2f *p1, QSPt2f *p2) const
virtual ClipResult clipPoly2 (const QSPt2f in[], int inpoints, QSPt2f out[], int *outpoints, int maxout, bool outedges[]=NULL, const bool inedges[]=NULL) const
virtual ClipResult clipPoint3 (const QSPt3f &pos) const
virtual ClipResult clipLine3 (QSPt3f *p1, QSPt3f *p2) const
virtual ClipResult clipPoly3 (const QSPt3f in[], int inpoints, QSPt3f out[], int *outpoints, int maxpoints, const QSPt3f cube[2], bool outedges[]=NULL, const bool inedges[]=NULL) const
virtual void shade (QSGFill &fill, const QSPt3f &normal, const QSPt2f *canvas_pts, int npoints, QSGFill *bottomFill) const

Static Public Methods

double degToRad (double deg)
double radToDeg (double rad)
bool pointInPoly (const QSPt2f &pos, const QSPt2f *pts, int npts)
double dotProduct (const QSPt3f &p1, const QSPt3f &p2)
QSPt3f vectorProduct (const QSPt3f &p1, const QSPt3f &p2)
QSPt3f normal (const QSPt3f vertices[4], bool normalize=true)
QSPt3f normal (const QSPt3f *v, int npoints, bool normalize=true)
QSPt3f normalize (QSPt3f vector)
void getPoly3Cube (const QSPt3f in[], int inpoints, QSPt3f cube[2])
ClipResult clipLine (QSPt2f *p0, QSPt2f *p1, const QSPt2f &clip_pos, const QSPt2f &clip_area)
void clipVertexNormals (const QSPt3f in[], int inpoints, const QSPt3f clip[], int clipoints, const QSPt3f innors[], QSPt3f outnor[])
void clipVertexColors (const QSPt3f in[], int inpoints, const QSPt3f clip[], int clipoints, const QSGFill incol[], QSGFill outcol[])
bool isBottom (const QSPt2f pts[], int npoints)
bool isBottom (const QSPt3f pts[], int npoints)
bool isBottom (const QSPt3f &p0, const QSPt3f &p1, const QSPt3f &p2)
bool isFlat (const QSPt3f pts[], int npoints)
bool isCorrect (const QSPt3f pts[4])
bool isCorrect (const double values[4])
void triangulate1 (int triangleNumber, const QSPt3f pts[], int npoints, QSPt3f triangle[3], bool edges[3])

Static Public Attributes

const double pi

Protected Attributes

bool m_light
QSPt3f m_light_vector
int m_ambient_light
int m_directed_light

Detailed Description

Base class for 2D,3D world -> screen transformations.

Transformations maps points from world coordinates ( 2d,3d space ) to screen(canvas) coordinates and also clips polygon and lines to the viewport. Each axes object such as QSAxes2D, QSAxes3D provides its own implementation of transformation object which can be acessed through this interface, see QSAxes::proj() There are two sets of functions: first which maps coordinates from 2D world to screen and the second, which maps coordinates from 3D world to screen. The first set should be used by 2d plots and the second should be used by 3d plots. Projection can treat mappings from world2D in a special way allowing plotting 2d datasets on a different planes etc. This will be detailed in the next version. Notice that QSAxes2D also provides world3DToCanvas() methods allowing drawing 3D datasets on 2D axes. Projection expect all world coordinates to be in range 0.0-1.0. see world2DToCanvas() and world2DToCanvas3() world3DToCanvas() world3DToCanvas3() furthest() middle() canvas3ToWorld3D()


Member Enumeration Documentation

enum QSProjection::ClipResult
 

Clipping result.

See also:
clipLine , clipPoly


Constructor & Destructor Documentation

QSProjection::QSProjection  
 

Constructor

virtual QSProjection::~QSProjection   [virtual]
 

Destructor


Member Function Documentation

int QSProjection::ambientLight   const [inline]
 

ambient light intensity ( -50,50 )

virtual QSPt3f QSProjection::canvas3ToWorld3D const QSPt3f   p const [pure virtual]
 

Maps 'p' from canvas coordinates to world coordinates.

Implemented in QSProjection2D.

virtual ClipResult QSProjection::clipLine2 QSPt2f   p1,
QSPt2f   p2
const [virtual]
 

Clips a line defined by 'p1' and 'p2' to the clipping rectangle. Returns a state of the operation: 'Clipped' - the line was clipped and coordinates of points were written to 'out', 'Rejected' - the line was thrown away ( coordinates not modified ), 'Accepted' - the line is inside the clipping rectangle ( coordinates were not modified ).

See also:
setClipRect

virtual ClipResult QSProjection::clipLine3 QSPt3f   p1,
QSPt3f   p2
const [virtual]
 

Clips line.

virtual ClipResult QSProjection::clipPoint2 const QSPt2f   p1 const [virtual]
 

Tests if point is inside the clipping area. Returns 'Rejected' or 'Accepted'.

virtual ClipResult QSProjection::clipPoint3 const QSPt3f   pos const [virtual]
 

Tests if point is inside the clipping space. Returns 'Rejected' or 'Accepted'.

virtual ClipResult QSProjection::clipPoly2 const QSPt2f    in[],
int    inpoints,
QSPt2f    out[],
int *    outpoints,
int    maxout,
bool    outedges[] = NULL,
const bool    inedges[] = NULL
const [virtual]
 

This method clips a polygon defined by 'npoints' points in 'in' to the clip rectangle and returns a new polygon in 'out'. Table 'out' must be large enough to contain all vertices after clipping. The maximum size of this table must be given as 'maxpoints'. If 'outedges' array is passed returns edges to be drawn ( those will be all unclipped edges ), you can pass a table with an initial edge state in 'inedges'. Returns a state of the operation: 'Clipped' - the polygon was clipped and coordinates of points were written to 'out', 'Rejected' - the polygon was thrown away ( coordinates in 'out...' were not modified ), 'Accepted' - the polygon is inside the clipping rectangle ( coordinates in 'out...' were not modified ).

See also:
setClipRect

virtual ClipResult QSProjection::clipPoly3 const QSPt3f    in[],
int    inpoints,
QSPt3f    out[],
int *    outpoints,
int    maxpoints,
const QSPt3f    cube[2],
bool    outedges[] = NULL,
const bool    inedges[] = NULL
const [virtual]
 

This method clips the polygon defined by 'npoints' points in 'in' to the axis box [(0,0,0),(1,1,1)] and returns a new mesh in 'out'. Table 'out' must be large enough to contain all vertices after clipping. The size of this table must be given in 'maxpoints'. If 'outedges' array is passed returns edges to be drawn ( those will be all unclipped edges ), you can pass a table with an initial edge state in 'inedges'. Returns a state of the operation: 'Clipped' - the polygon was clipped and coordinates of points were written to 'out', 'Rejected' - the polygon was thrown away ( coordinates not modified ), 'Acccepted' - the polygon is inside the axis box ( coordinates were not modified ).

void QSProjection::clipVertexColors const QSPt3f    in[],
int    inpoints,
const QSPt3f    clip[],
int    clipoints,
const QSGFill    incol[],
QSGFill    outcol[]
[static]
 

Calculates interpolated colors. With the given polygon defined by 'inpoints' vertices 'in[]', and colors of those vertices in 'incols[]', calculates colors at 'clippoints' points 'clip[]' interpolating respective colors of the polygon and writes them to 'outcols[]', which must have size equal to 'clippoints'. All points in 'clip[]' must lie inside the given polygon.

void QSProjection::clipVertexNormals const QSPt3f    in[],
int    inpoints,
const QSPt3f    clip[],
int    clipoints,
const QSPt3f    innors[],
QSPt3f    outnor[]
[static]
 

Calculates interpolated normals. With the given polygon defined by 'inpoint' vertices 'in[]', and normals to those vertices in 'innors[]', calculates normals at 'clippoints' points 'clip[]' interpolating respective normals of the polygon and writes them to 'outnors[]', which must have size equal to 'clippoints'. All points in 'clip[]' must lie inside the given polygon.

double QSProjection::degToRad double    deg [inline, static]
 

Degrees to radians

int QSProjection::directedLight   const [inline]
 

directed light intensity ( -50, 50 )

double QSProjection::dotProduct const QSPt3f   p1,
const QSPt3f   p2
[static]
 

Returns 'p1 * p2' .

virtual QSPt3f QSProjection::furthest   const [virtual]
 

Returns a point from [(0, 0, 0) ( 1, 1, 1 )] cube, which has the greatest z coordinate and all its three neighbourng walls are visible.

See also:
QSProjection3D::T

Reimplemented in QSProjection3D.

void QSProjection::getPoly3Cube const QSPt3f    in[],
int    inpoints,
QSPt3f    cube[2]
[static]
 

Calculates a bounding box of the polygon defined by 'inpoints' vertices in in[] and writes it to the 'cube[]' table.

bool QSProjection::isBottom const QSPt3f   p0,
const QSPt3f   p1,
const QSPt3f   p2
[inline, static]
 

The special version for triangles of the above function. All points are in canvas coordinates.

bool QSProjection::isBottom const QSPt3f    pts[],
int    npoints
[static]
 

Checks wheather a bottom side of the given polygon is visible. All points are in canvas coordinates.

bool QSProjection::isBottom const QSPt2f    pts[],
int    npoints
[static]
 

Checks wheather a bottom side of the given polygon is visible. All points are in canvas coordinates.

bool QSProjection::isFlat const QSPt3f    pts[],
int    npoints
[static]
 

Triangulates the given polygon and checks if all triangles have the same side visible ( all have top or all have the bottom side visible ). All points are in canvas coordinates.

bool QSProjection::light   const [inline]
 

Is light turned on ?

QSPt3f QSProjection::lightVector   const [inline]
 

light direction - normalized vector

virtual QSPt2f QSProjection::middle   const [virtual]
 

Middle point

Reimplemented in QSProjection3D.

QSPt3f QSProjection::normal const QSPt3f   v,
int    npoints,
bool    normalize = true
[static]
 

Returns the normal to the given polygon.

QSPt3f QSProjection::normal const QSPt3f    vertices[4],
bool    normalize = true
[static]
 

Returns the normal to the given quad.

QSPt3f QSProjection::normalize QSPt3f    vector [static]
 

Normalize vector.

bool QSProjection::pointInPoly const QSPt2f   pos,
const QSPt2f   pts,
int    npts
[static]
 

Tests if point 'pos' is inside polygon 'pts'. No need to reimplement.

double QSProjection::radToDeg double    rad [inline, static]
 

Radians to degrees

virtual void QSProjection::setLight bool    enabled [virtual]
 

Turns on lighting.

virtual void QSProjection::setLightParameters const QSPt3f   lightVector,
int    ambientLight,
int    directedLight
[virtual]
 

Sets light parameters

virtual void QSProjection::shade QSGFill   fill,
const QSPt3f   normal,
const QSPt2f   canvas_pts,
int    npoints,
QSGFill   bottomFill
const [virtual]
 

Shades 'fill' color.

QSPt3f QSProjection::vectorProduct const QSPt3f   p1,
const QSPt3f   p2
[static]
 

Returns 'p1 x p2' .

virtual QSPt2f QSProjection::world2DToCanvas const QSPt2f   p const [pure virtual]
 

Maps the point to the screen coordinates - the same as world2DToCanvas3() but the depth is not returned. Provided only for efficiency.

Implemented in QSProjection2D.

virtual QSPt3f QSProjection::world2DToCanvas3 const QSPt2f   p const [pure virtual]
 

Maps the point to the screen coordinates+depth.

Implemented in QSProjection2D.

virtual QSPt2f QSProjection::world3DToCanvas const QSPt3f   p const [pure virtual]
 

Maps 'p' to the screen coordinates. - the same as world3DToCanvas3() but the depth not returned. Provided only for efficiency.

Implemented in QSProjection2D.

virtual QSPt3f QSProjection::world3DToCanvas3 const QSPt3f   p const [pure virtual]
 

Maps 'p' to the screen coordinates.+ depth

Implemented in QSProjection2D.


Member Data Documentation

const double QSProjection::pi [static]
 

PI


The documentation for this class was generated from the following file:
Generated on Mon Mar 18 19:16:52 2002 for KMatplot library by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002