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

Txq2dLineSeg Class Reference

Txq2dLineSeg is a line segement with internal data of endpoints, The line can be defined by specifying the two end points. More...

#include <Txq2dLineSeg.h>

Inheritance diagram for Txq2dLineSeg::

Txq2dSeg Txq2dDrawable TxqDrawable Txq2dLine Txq2dVector List of all members.

Public Methods

 Txq2dLineSeg ()
 Default construction of a Txq2dLineSeg with the default start and end points and default color white. More...

 Txq2dLineSeg (int x1, int y1, int x2, int y2)
 Constructs with the starting and ending points of the line segment in the real-world cartesian coordinates,. More...

 Txq2dLineSeg (QPoint p1, QPoint p2)
 Constructs with the starting and ending points of the line segment in the real-world cartesian coordinates. More...

 Txq2dLineSeg (TxqDoublePoint p1, TxqDoublePoint p2)
 Constructs with the starting and ending points of the line segment in the real-world cartesian coordinates. More...

 Txq2dLineSeg (double x1, double y1, double x2, double y2)
 Constructs with the starting and ending points of the line segment in the real-world cartesian coordinates. More...

virtual ~Txq2dLineSeg ()
 The destructor. More...

void calculateParameters ()
 Calculates the slope, intercept, angle, and bounds of the segment given the current start and end points. More...

void setBoundsToPoints ()
 Recalculates the bounds given the current starting and ending points. More...

void setPoints (int x1, int y1, int x2, int y2)
 Set the starting and ending points of the line segment in the real-world cartesian coordinates,. More...

void setPoints (QPoint p1, QPoint p2)
 Set the starting and ending points of the line segment in the real-world cartesian coordinates. More...

void setPoints (TxqDoublePoint p1, TxqDoublePoint p2)
 Set the starting and ending points of the line segment in the real-world cartesian coordinates. More...

void setPoints (double x1, double y1, double x2, double y2)
 Set the starting and ending points of the line segment in the real-world cartesian coordinates. More...

void setStartPoint (TxqDoublePoint sp)
 Set the starting point of the line segment in the real-world cartesian coordinates. More...

void setStartPoint (int x, int y)
 Set the starting point of the line segment in the real-world cartesian coordinates. More...

void setEndPoint (TxqDoublePoint ep)
 Set the ending point of the line segment in the real-world cartesian coordinates. More...

void setEndPoint (int x, int y)
 Set the ending point of the line segment in the real-world cartesian coordinates. More...

void setPointAndAngle (TxqDoublePoint sp, double myAngle)
 Resets the line segment to one starting from the point {x1,y1}, having slope m, and having a size marked off by dx in the x-direction and dy in the y-direction. More...

void stretchToMax ()
 Stretches current line to a large boundary. More...

void setAngle (double myAngle)
 Set the slope of the ray. More...

void setSlope (double m)
 Set the slope of the line keeping the same intercept. More...

double getSlope ()
 Gets the current slope. More...

void setIntercept (double b)
 Set the y-intercept of the line keeping the same slope. More...

double getIntercept ()
 Gets the current y-intercept. More...

int findY (int x)
 Returns the y value of the line at the specified x position. More...

double findY (double x)
 Returns the y value of the line at the specified x position. More...

int findX (int y)
 Returns the x value of the line at the specified y position. More...

double findX (double y)
 Returns the x value of the line at the specified y position. More...

TxqDoublePoint intersection (TxqDoublePoint p, double m)
 Finds the interscetion point of this Txq2dLineSeg with the the ray segment specified by the starting point and slope. More...

TxqDoublePoint intersection (Txq2dLineSeg segline)
 Returns the intersection point of this line segment and the specified line segment. More...

QPoint getPointAtPosition (int pixels)
 Returns the Point on the ray segment that corresponds to the specified number of pixels away from the start point. More...

bool inBetweenEnds (TxqDoublePoint p)
 Returns a bool telling whether a specified point lies inside the bounds defined by the two endpoints. More...

bool onLineSegment (TxqDoublePoint p)
 Returns a bool telling whether a specified point lies on the line segment. More...

void findCenterFromBounds ()
 Makes a center of rotation the starting point instead of the center of the bounds. More...

void paint (QPainter *g)
 Paints the line using the end points. More...

void dump (QTextStream *ts)
 Dump the objects contents to the text stream ts. More...


Protected Methods

virtual void initialize ()
 initialize the class data members. More...


Private Attributes

double slope
 The slope value. More...

double intercept
 The intercept value. More...

int numPoints
 number of points in the line segment. More...


Static Private Attributes

const double MAX_SIZE
 A MAX_SIXE constant. More...


Detailed Description

Txq2dLineSeg is a line segement with internal data of endpoints, The line can be defined by specifying the two end points.

Caution: Much of this class is not tested. One should be careful with the slope intercept and bound calculations.

Copyright 2000 by Tech-X Corporation

Author:
Kelly G. Luetkemeyer

Version:
Id:
Txq2dLineSeg.h,v 1.5 2002/01/17 19:29:21 kgl Exp

Definition at line 42 of file Txq2dLineSeg.h.


Constructor & Destructor Documentation

Txq2dLineSeg::Txq2dLineSeg ( )
 

Default construction of a Txq2dLineSeg with the default start and end points and default color white.

Txq2dLineSeg::Txq2dLineSeg ( int x1,
int y1,
int x2,
int y2 )
 

Constructs with the starting and ending points of the line segment in the real-world cartesian coordinates,.

Parameters:
x1   the starting x integer point
y1   the starting y integer point
x2   the ending x integer point
y2   the ending y integer point

Txq2dLineSeg::Txq2dLineSeg ( QPoint p1,
QPoint p2 )
 

Constructs with the starting and ending points of the line segment in the real-world cartesian coordinates.

Parameters:
p1   the starting QPoint
p2   the ending QPoint

Txq2dLineSeg::Txq2dLineSeg ( TxqDoublePoint p1,
TxqDoublePoint p2 )
 

Constructs with the starting and ending points of the line segment in the real-world cartesian coordinates.

Parameters:
p1   the starting point
p2   the ending point

Txq2dLineSeg::Txq2dLineSeg ( double x1,
double y1,
double x2,
double y2 )
 

Constructs with the starting and ending points of the line segment in the real-world cartesian coordinates.

Parameters:
x1   the starting x double point
y1   the starting y double point
x2   the ending x double point
y2   the ending y double point

Txq2dLineSeg::~Txq2dLineSeg ( ) [virtual]
 

The destructor.


Member Function Documentation

void Txq2dLineSeg::calculateParameters ( )
 

Calculates the slope, intercept, angle, and bounds of the segment given the current start and end points.

void Txq2dLineSeg::dump ( QTextStream * ts ) [virtual]
 

Dump the objects contents to the text stream ts.

Parameters:
ts   the text stream

Reimplemented from TxqDrawable.

Reimplemented in Txq2dLine, and Txq2dVector.

void Txq2dLineSeg::findCenterFromBounds ( )
 

Makes a center of rotation the starting point instead of the center of the bounds.

Reimplemented from TxqDrawable.

double Txq2dLineSeg::findX ( double y )
 

Returns the x value of the line at the specified y position.

If the lines is horizontal then infinity is returned.

Parameters:
the   y position

int Txq2dLineSeg::findX ( int y )
 

Returns the x value of the line at the specified y position.

If the lines is horizontal then infinity is returned.

Parameters:
the   y position

double Txq2dLineSeg::findY ( double x )
 

Returns the y value of the line at the specified x position.

If the lines is vertical then zero is returned.

Parameters:
the   x position

int Txq2dLineSeg::findY ( int x )
 

Returns the y value of the line at the specified x position.

If the lines is vertical then zero is returned.

Parameters:
the   x position

double Txq2dLineSeg::getIntercept ( )
 

Gets the current y-intercept.

QPoint Txq2dLineSeg::getPointAtPosition ( int pixels )
 

Returns the Point on the ray segment that corresponds to the specified number of pixels away from the start point.

Parameters:
pixels   the pixel position

double Txq2dLineSeg::getSlope ( )
 

Gets the current slope.

bool Txq2dLineSeg::inBetweenEnds ( TxqDoublePoint p )
 

Returns a bool telling whether a specified point lies inside the bounds defined by the two endpoints.

Parameters:
p   the point to use

void Txq2dLineSeg::initialize ( ) [protected, virtual]
 

initialize the class data members.

Reimplemented from TxqDrawable.

Reimplemented in Txq2dLine, and Txq2dVector.

TxqDoublePoint Txq2dLineSeg::intersection ( Txq2dLineSeg segline )
 

Returns the intersection point of this line segment and the specified line segment.

Parameters:
segLine   the Txq2dLineSeg to use

TxqDoublePoint Txq2dLineSeg::intersection ( TxqDoublePoint p,
double m )
 

Finds the interscetion point of this Txq2dLineSeg with the the ray segment specified by the starting point and slope.

Parameters:
p   starting point of ray segment
m   slope of ray segment

bool Txq2dLineSeg::onLineSegment ( TxqDoublePoint p )
 

Returns a bool telling whether a specified point lies on the line segment.

Parameters:
p   the point to use

void Txq2dLineSeg::paint ( QPainter * g ) [virtual]
 

Paints the line using the end points.

Parameters:
g   the QPainter device to use.

Reimplemented from Txq2dSeg.

Reimplemented in Txq2dLine, and Txq2dVector.

void Txq2dLineSeg::setAngle ( double myAngle )
 

Set the slope of the ray.

This takes the starting point previous set and along with the specified angle and then calls setPointAndAngle.

Parameters:
myAngle   to angle to set the point

Reimplemented from TxqDrawable.

void Txq2dLineSeg::setBoundsToPoints ( )
 

Recalculates the bounds given the current starting and ending points.

void Txq2dLineSeg::setEndPoint ( int x,
int y )
 

Set the ending point of the line segment in the real-world cartesian coordinates.

Parameters:
x   the ending x point
y   the ending x point

void Txq2dLineSeg::setEndPoint ( TxqDoublePoint ep )
 

Set the ending point of the line segment in the real-world cartesian coordinates.

Parameters:
ep   the ending point

Reimplemented from Txq2dSeg.

void Txq2dLineSeg::setIntercept ( double b )
 

Set the y-intercept of the line keeping the same slope.

This is equivalent to translating the line up or down.

Parameters:
b   the intercept value

void Txq2dLineSeg::setPointAndAngle ( TxqDoublePoint sp,
double myAngle )
 

Resets the line segment to one starting from the point {x1,y1}, having slope m, and having a size marked off by dx in the x-direction and dy in the y-direction.

Parameters:
sp   the point to set
myAngle   to angle to set the point

void Txq2dLineSeg::setPoints ( double x1,
double y1,
double x2,
double y2 )
 

Set the starting and ending points of the line segment in the real-world cartesian coordinates.

Parameters:
x1   the starting x double point
y1   the starting y double point
x2   the ending x double point
y2   the ending y double point

void Txq2dLineSeg::setPoints ( TxqDoublePoint p1,
TxqDoublePoint p2 )
 

Set the starting and ending points of the line segment in the real-world cartesian coordinates.

Parameters:
p1   the starting point
p2   the ending point

void Txq2dLineSeg::setPoints ( QPoint p1,
QPoint p2 )
 

Set the starting and ending points of the line segment in the real-world cartesian coordinates.

Parameters:
p1   the starting QPoint
p2   the ending QPoint

void Txq2dLineSeg::setPoints ( int x1,
int y1,
int x2,
int y2 )
 

Set the starting and ending points of the line segment in the real-world cartesian coordinates,.

Parameters:
x1   the starting x integer point
y1   the starting y integer point
x2   the ending x integer point
y2   the ending y integer point

void Txq2dLineSeg::setSlope ( double m )
 

Set the slope of the line keeping the same intercept.

This is like rotating the line about the y-intercept point.

Parameters:
m   the slope of the line

void Txq2dLineSeg::setStartPoint ( int x,
int y )
 

Set the starting point of the line segment in the real-world cartesian coordinates.

Parameters:
x   the starting x point
y   the starting y point

void Txq2dLineSeg::setStartPoint ( TxqDoublePoint sp )
 

Set the starting point of the line segment in the real-world cartesian coordinates.

Parameters:
sp   the starting point

Reimplemented from Txq2dSeg.

void Txq2dLineSeg::stretchToMax ( )
 

Stretches current line to a large boundary.


Member Data Documentation

const double Txq2dLineSeg::MAX_SIZE [static, private]
 

A MAX_SIXE constant.

Definition at line 340 of file Txq2dLineSeg.h.

double Txq2dLineSeg::intercept [private]
 

The intercept value.

Definition at line 335 of file Txq2dLineSeg.h.

int Txq2dLineSeg::numPoints [private]
 

number of points in the line segment.

Definition at line 345 of file Txq2dLineSeg.h.

double Txq2dLineSeg::slope [private]
 

The slope value.

Definition at line 330 of file Txq2dLineSeg.h.


The documentation for this class was generated from the following file: Copyright Tech-X Corporation, all rights reserved.