aboutsummaryrefslogtreecommitdiff
path: root/generic/Geo.c
diff options
context:
space:
mode:
authorlecoanet2000-03-07 15:01:30 +0000
committerlecoanet2000-03-07 15:01:30 +0000
commite315c7e0d3cbfd4bc72f3fc3ec5bc2384cd4fa80 (patch)
tree67398a7091e57da5cefc96913ec071a4ef05dc53 /generic/Geo.c
parentf7a8a6e6ae70b1bd4665b9251e40c746ffab40bf (diff)
downloadtkzinc-e315c7e0d3cbfd4bc72f3fc3ec5bc2384cd4fa80.zip
tkzinc-e315c7e0d3cbfd4bc72f3fc3ec5bc2384cd4fa80.tar.gz
tkzinc-e315c7e0d3cbfd4bc72f3fc3ec5bc2384cd4fa80.tar.bz2
tkzinc-e315c7e0d3cbfd4bc72f3fc3ec5bc2384cd4fa80.tar.xz
* D�placement de fonctions g�om�triques vers Geo.
Diffstat (limited to 'generic/Geo.c')
-rw-r--r--generic/Geo.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/generic/Geo.c b/generic/Geo.c
index 16cee3e..cf07dc3 100644
--- a/generic/Geo.c
+++ b/generic/Geo.c
@@ -498,6 +498,9 @@ ShiftLine(ZnPoint *p1,
else {
dy_neg = False;
}
+ if ((dy == 0) && (dx == 0)) {
+ return;
+ }
if (dy <= dx) {
dy = ((dist * shift_table[(dy*128)/dx]) + 64) / 128;
if (!dx_neg) {
@@ -1072,6 +1075,58 @@ PointInAngle(int start_angle,
((angle_extent < 0) && ((angle_diff - 360) >= angle_extent)));
}
+/*
+ * PointPolarToCartesian --
+ * Convert a point in polar coordinates (rho, theta)
+ * in a reference system described by angle heading
+ * (angles running clockwise) to a point in cartesian
+ * coordinates (delta_x, delta_y).
+ *
+ */
+void
+PointPolarToCartesian(ZnReal heading,
+ int rho,
+ int theta,
+ int *delta_x,
+ int *delta_y)
+{
+ double to_angle;
+
+ /* Compute angle in trigonometric system */
+ to_angle = DegreesToRadian(theta) + heading - M_PI_2;
+ /* to_angle = heading - DegreesToRadian(theta);*/
+ /* Compute cartesian coordinates */
+ *delta_x = (int) (rho * cos(to_angle));
+ *delta_y = (int) (rho * sin(to_angle));
+}
+
+/*
+ * Return a vector angle given its projections
+ */
+ZnReal
+ProjectionToAngle(ZnDim dx,
+ ZnDim dy)
+{
+ if (dx == 0) {
+ if (dy < 0) {
+ return -M_PI_2;
+ }
+ else if (dy > 0) {
+ return M_PI_2;
+ }
+ else {
+ return 0.0;
+ }
+ }
+ else if (dx < 0) {
+ return atan((double) dy / (double) dx) - M_PI;
+ }
+ else {
+ return atan((double) dy / (double) dx);
+ }
+ return 0.0;
+}
+
/*
* Tell if an horizontal line intersect an axis aligned