#include <InstrumentUtil.h>
|
| static bool | CohenSutherlandLineClip (double &x0, double &y0, double &x1, double &y1, double xmin, double xmax, double ymin, double ymax) |
| | Cohen–Sutherland clipping algorithm clips a line from P0 = (x0, y0) to P1 = (x1, y1) against a rectangle with diagonal from (xmin, ymin) to (xmax, ymax). More...
|
| |
|
| static const int | INSIDE = 0 |
| |
| static const int | LEFT = 1 |
| |
| static const int | RIGHT = 2 |
| |
| static const int | BOTTOM = 4 |
| |
| static const int | TOP = 8 |
| |
◆ OutCode
◆ CohenSutherlandLineClip()
| bool InstrumentUtil::CohenSutherlandLineClip |
( |
double & |
x0, |
|
|
double & |
y0, |
|
|
double & |
x1, |
|
|
double & |
y1, |
|
|
double |
xmin, |
|
|
double |
xmax, |
|
|
double |
ymin, |
|
|
double |
ymax |
|
) |
| |
|
static |
Cohen–Sutherland clipping algorithm clips a line from P0 = (x0, y0) to P1 = (x1, y1) against a rectangle with diagonal from (xmin, ymin) to (xmax, ymax).
Returns true if the line segment is intersecting with the rectangle, false otherwise.
36 if (!(outcode0 | outcode1)) {
40 else if (outcode0 & outcode1) {
49 OutCode outcodeOut = outcode0 ? outcode0 : outcode1;
53 if (outcodeOut &
TOP) {
54 x = x0 + (x1 - x0) * (ymax - y0) / (y1 - y0);
57 else if (outcodeOut &
BOTTOM) {
58 x = x0 + (x1 - x0) * (ymin - y0) / (y1 - y0);
61 else if (outcodeOut &
RIGHT) {
62 y = y0 + (y1 - y0) * (xmax - x0) / (x1 - x0);
65 else if (outcodeOut &
LEFT) {
66 y = y0 + (y1 - y0) * (xmin - x0) / (x1 - x0);
72 if (outcodeOut == outcode0) {
Referenced by inet::PlotFigure::plot().
◆ ComputeOutCode()
| InstrumentUtil::OutCode InstrumentUtil::ComputeOutCode |
( |
double |
x, |
|
|
double |
y, |
|
|
double |
xmin, |
|
|
double |
xmax, |
|
|
double |
ymin, |
|
|
double |
ymax |
|
) |
| |
|
staticprivate |
◆ BOTTOM
| const int InstrumentUtil::BOTTOM = 4 |
|
staticprivate |
◆ INSIDE
| const int InstrumentUtil::INSIDE = 0 |
|
staticprivate |
◆ LEFT
| const int InstrumentUtil::LEFT = 1 |
|
staticprivate |
◆ RIGHT
| const int InstrumentUtil::RIGHT = 2 |
|
staticprivate |
◆ TOP
| const int InstrumentUtil::TOP = 8 |
|
staticprivate |
The documentation for this class was generated from the following files: