#include "spice.h"
#include "plotdefs.h"
Go to the source code of this file.
|
bool | clip_line (int *pX1, int *pY1, int *pX2, int *pY2, int l, int b, int r, int t) |
|
bool | clip_to_circle (int *x1, int *y1, int *x2, int *y2, int cx, int cy, int rad) |
|
Value:
Definition at line 21 of file clip.c.
#define MAX |
( |
|
a, |
|
|
|
b |
|
) |
| (((a) > (b)) ? (a) : (b)) |
#define MIN |
( |
|
a, |
|
|
|
b |
|
) |
| (((a) < (b)) ? (a) : (b)) |
#define SWAM_PINT |
( |
|
a, |
|
|
|
b |
|
) |
| { int xxxx = (a); (a) = (b); (b) = xxxx; } |
bool clip_line |
( |
int * |
pX1, |
|
|
int * |
pY1, |
|
|
int * |
pX2, |
|
|
int * |
pY2, |
|
|
int |
l, |
|
|
int |
b, |
|
|
int |
r, |
|
|
int |
t |
|
) |
| |
Definition at line 42 of file clip.c.
59 y = y1+(y2-y1)*(
l-x1)/(x2-x1);
62 y = y1+(y2-y1)*(
r-x1)/(x2-x1);
65 x = x1+(x2-x1)*(b-y1)/(y2-y1);
68 x = x1+(x2-x1)*(
t-y1)/(y2-y1);
while(TDesc->tSucc!=NULL)
bool clip_to_circle |
( |
int * |
x1, |
|
|
int * |
y1, |
|
|
int * |
x2, |
|
|
int * |
y2, |
|
|
int |
cx, |
|
|
int |
cy, |
|
|
int |
rad |
|
) |
| |
Definition at line 95 of file clip.c.
98 double perplen,
a, b,
c;
101 double theta1, theta2,
tt, alpha, beta, gamma;
106 if ((*x1-cx) || (*y1-cy))
107 theta1 = atan2((
double) *y1 - cy, (
double) *x1 - cx);
110 if ((*x2-cx) || (*y2-cy))
111 theta2 = atan2((
double) *y2 - cy, (
double) *x2 - cx);
116 theta1 = 2 *
M_PI + theta1;
118 theta2 = 2 *
M_PI + theta2;
120 dtheta = theta2 - theta1;
122 dtheta = dtheta - 2 *
M_PI;
123 else if (dtheta < - M_PI)
124 dtheta = 2 * M_PI - dtheta;
142 a = sqrt((
double) ((*x1 - cx) * (*x1 - cx) + (*y1 - cy) * (*y1 - cy)));
143 b = sqrt((
double) ((*x2 - cx) * (*x2 - cx) + (*y2 - cy) * (*y2 - cy)));
144 c = sqrt((
double) ((*x1 - *x2) * (*x1 - *x2) +
145 (*y1 - *y2) * (*y1 - *y2)));
153 tx = (*x1 + *x2) / 2;
154 ty = (*y1 + *y2) / 2;
155 dt = sqrt((
double) ((tx - cx) * (tx - cx) + (ty - cy) * (ty - cy)));
156 if ((dt < a) && (dt < b)) {
158 tt = (a * a + c * c - b * b) / (2 * a * c);
164 perplen = a *
sin(alpha);
177 tt = (a * a + c * c - b * b) / (2 * a * c);
183 gamma = asin(
sin(alpha) * a / rad);
184 if (gamma < M_PI / 2)
185 gamma = M_PI - gamma;
186 beta = M_PI - alpha - gamma;
187 *x1 = cx + rad *
cos(theta1 + beta);
188 *y1 = cy + rad *
sin(theta1 + beta);
191 tt = (c * c + b * b - a * a) / (2 * b * c);
197 gamma = asin(
sin(alpha) * b / rad);
198 if (gamma < M_PI / 2)
199 gamma = M_PI - gamma;
200 beta = M_PI - alpha - gamma;
201 *x2 = cx + rad *
cos(theta2 - beta);
202 *y2 = cy + rad *
sin(theta2 - beta);