#include <segment.h>
Public Member Functions | |
| Segment () | |
| Constructor. | |
| Segment (const Coordinates &f, const Coordinates &t) | |
| Constructor. | |
| Segment (const Coordinates &f, const Coordinates &t, const Color &c) | |
| Constructor. | |
| virtual | ~Segment () |
| Destructor. | |
| Segment (const Segment &s) | |
| Copy constructor. | |
| void | set_from (const Coordinates &c) |
| Set the start point. | |
| void | set_to (const Coordinates &c) |
| Set the end point. | |
| void | set (const Coordinates &f, const Coordinates &t) |
| Set the start and end point. | |
| void | set_pol (const Coordinates &f, double length, double angle, Angle_Type at=ANG_RAD) |
| Defines the Segment in terms of start point, length, and angle. | |
| void | set_color (const Color &c) |
| Set the color. | |
| void | color (const Color &c) |
| Set the color. | |
| void | get_from (Coordinates &f) const |
| Get the start point. | |
| Coordinates | get_from () const |
| Get the start point. | |
| void | get_to (Coordinates &t) const |
| Get the end point. | |
| Coordinates | get_to () const |
| Get the end point. | |
| void | get (Coordinates &f, Coordinates &t) const |
| Get the end and start point. | |
| Color | get_color () const |
| Get the color of the segment. | |
| Color | color () const |
| Get the color of the segment. | |
| double | length () const |
| Get the length of the segment. | |
| double | angle (Angle_Type at=ANG_RAD) const |
| Get the angle of the segment. | |
| void | move_to (const Coordinates &c) |
| Move the segment to a new start point. | |
| void | move_by (const Coordinates &c) |
| Move the segment. | |
| void | draw (Drawer &d) const |
| Draw the segment. | |
| const Segment & | operator= (const Segment &s) |
| Assignment operator. | |
Private Attributes | |
| Color | s_color |
| The color of the segment. | |
| Coordinates | from |
| The start point. | |
| Coordinates | to |
| The end point. | |
| double | initial_length |
| The length of the segment. | |
| double | initial_angle |
| The angle of the segment. | |
y
/\
| * (x1/y1)
| /
| /
| /
| * (x0/y0)
|
|
|
-----+-----------------> x
(0/0)|
The class does not provide any methods for drawing the segment. For that, it relies on Drawer.
| Segment::Segment | ( | ) |
Constructor.
| Segment::Segment | ( | const Coordinates & | f, | |
| const Coordinates & | t | |||
| ) |
Sets start and end point.
| f | Start point. | |
| t | End point. |
| Segment::Segment | ( | const Coordinates & | f, | |
| const Coordinates & | t, | |||
| const Color & | c | |||
| ) |
| Segment::~Segment | ( | ) | [virtual] |
Destructor. Does nothing. Just for completeness.
| Segment::Segment | ( | const Segment & | s | ) |
| void Segment::set_from | ( | const Coordinates & | c | ) |
| void Segment::set_to | ( | const Coordinates & | c | ) |
Sets the end point.
| c | A const reference to a Cooridnates object. |
| void Segment::set | ( | const Coordinates & | f, | |
| const Coordinates & | t | |||
| ) |
Sets the start and end point.
| f | A const reference to a Coordinates object as the start point. | |
| t | A const reference to a Coordinates object as the end point. |
| void Segment::set_pol | ( | const Coordinates & | f, | |
| double | length, | |||
| double | angle, | |||
| Angle_Type | at = ANG_RAD | |||
| ) |
Draws a Segment from f with the specified length under the the specified angle.
| f | A const reference to a Coordinates object as the start point. | |
| length | Length of the Segment. | |
| angle | Angle of the segment with respect to the x-axis. | |
| at | Unit of angle. See Angle_Type. |
| void GVectors::Segment::set_color | ( | const Color & | c | ) | [inline] |
| void GVectors::Segment::color | ( | const Color & | c | ) | [inline] |
| void Segment::get_from | ( | Coordinates & | f | ) | const |
Gets the start point of the segment.
| f | A reference to a Coordinates object receiving the x and y values of the start point. |
| Coordinates Segment::get_from | ( | ) | const |
Gets the start point of the segment.
| void Segment::get_to | ( | Coordinates & | t | ) | const |
Gets the end point of the segment.
| t | A reference to a Coordinates object receiving the x and y values of the end point. |
| Coordinates Segment::get_to | ( | ) | const |
Gets the end point of the segment.
| void Segment::get | ( | Coordinates & | f, | |
| Coordinates & | t | |||
| ) | const |
Gets the start and end point of the segment.
| f | A reference to a Coordinates object receiving the x and y values of the start point. | |
| t | A reference to a Coordinates object receiving the x and y values of the end point. |
| Color GVectors::Segment::get_color | ( | ) | const [inline] |
| Color GVectors::Segment::color | ( | ) | const [inline] |
| double Segment::length | ( | ) | const |
Computes the length of the segment.
| double Segment::angle | ( | Angle_Type | at = ANG_RAD |
) | const |
Computes the angle of the segment with respect to the x-axis.
| at | The unit of the angle returned. |
| void Segment::move_to | ( | const Coordinates & | c | ) |
Moves the segment to a new start point.
| c | A const reference to a Coordinates serving as the new start point. |
| void Segment::move_by | ( | const Coordinates & | c | ) |
Moves the segment by c units in x and y direction.
| c | A const reference to a Coordinates object holding the units to move the segment. |
| void Segment::draw | ( | Drawer & | d | ) | const |
Assignment operator.
| s | A const reference to the Segment object assigned to this. |
Color GVectors::Segment::s_color [private] |
The color of the segment.
Coordinates GVectors::Segment::from [private] |
The starting point of the segment.
Coordinates GVectors::Segment::to [private] |
The end point of the segment.
double GVectors::Segment::initial_length [private] |
Holds the length of the segment.
double GVectors::Segment::initial_angle [private] |
The angle of the segment in relation to the x-axis.
1.4.7