aboutsummaryrefslogtreecommitdiff
path: root/generic/Transfo.c
diff options
context:
space:
mode:
authorlecoanet2000-02-02 14:01:15 +0000
committerlecoanet2000-02-02 14:01:15 +0000
commit64089dca388f5a9a8235a94b4372763875132219 (patch)
tree0455fa06d471a568cbece8fc27cde0216d4def23 /generic/Transfo.c
parent2b91521b4c124546e59638f2e990dcbc75903d85 (diff)
downloadtkzinc-64089dca388f5a9a8235a94b4372763875132219.zip
tkzinc-64089dca388f5a9a8235a94b4372763875132219.tar.gz
tkzinc-64089dca388f5a9a8235a94b4372763875132219.tar.bz2
tkzinc-64089dca388f5a9a8235a94b4372763875132219.tar.xz
Passage en Zinc
Diffstat (limited to 'generic/Transfo.c')
-rw-r--r--generic/Transfo.c196
1 files changed, 98 insertions, 98 deletions
diff --git a/generic/Transfo.c b/generic/Transfo.c
index aa50303..0d7e95e 100644
--- a/generic/Transfo.c
+++ b/generic/Transfo.c
@@ -77,19 +77,19 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ "
/*
*************************************************************************
*
- * RadarTransfoNew --
+ * ZnTransfoNew --
* Create a new transformation and return it initialized to
* identity.
*
*************************************************************************
*/
-RadarTransfo *
-RadarTransfoNew()
+ZnTransfo *
+ZnTransfoNew()
{
- RadarTransfo *t;
+ ZnTransfo *t;
- t = (RadarTransfo *) malloc(sizeof(RadarTransfo));
- RadarTransfoSetIdentity(t);
+ t = (ZnTransfo *) malloc(sizeof(ZnTransfo));
+ ZnTransfoSetIdentity(t);
return t;
}
@@ -98,22 +98,22 @@ RadarTransfoNew()
/*
*************************************************************************
*
- * RadarTransfoDuplicate --
+ * ZnTransfoDuplicate --
* Create a new transformation identical to the model t.
*
*************************************************************************
*/
-RadarTransfo *
-RadarTransfoDuplicate(RadarTransfo *t)
+ZnTransfo *
+ZnTransfoDuplicate(ZnTransfo *t)
{
- RadarTransfo *nt;
+ ZnTransfo *nt;
- nt = (RadarTransfo *) RadarMalloc(sizeof(RadarTransfo));
+ nt = (ZnTransfo *) ZnMalloc(sizeof(ZnTransfo));
if (t) {
*nt = *t;
}
else {
- RadarTransfoSetIdentity(nt);
+ ZnTransfoSetIdentity(nt);
}
return nt;
@@ -123,28 +123,28 @@ RadarTransfoDuplicate(RadarTransfo *t)
/*
*************************************************************************
*
- * RadarTransfoFree --
+ * ZnTransfoFree --
* Delete a transformation and free its memory.
*
*************************************************************************
*/
void
-RadarTransfoFree(RadarTransfo *t)
+ZnTransfoFree(ZnTransfo *t)
{
- RadarFree(t);
+ ZnFree(t);
}
/*
*************************************************************************
*
- * RadarPrintTransfo --
+ * ZnPrintTransfo --
* Print the transfo matrix on stdout.
*
*************************************************************************
*/
void
-RadarPrintTransfo(RadarTransfo *t)
+ZnPrintTransfo(ZnTransfo *t)
{
printf("(%5g %5g\n %5g %5g\n %5g %5g)\n",
t->_[0][0], t->_[0][1],
@@ -156,16 +156,16 @@ RadarPrintTransfo(RadarTransfo *t)
/*
*************************************************************************
*
- * RadarTransfoIsIdentity --
+ * ZnTransfoIsIdentity --
* Tell if the given transfo is (close to) identity.
*
*************************************************************************
*/
-RadarBool
-RadarTransfoIsIdentity(RadarTransfo *t)
+ZnBool
+ZnTransfoIsIdentity(ZnTransfo *t)
{
- RadarReal tmp;
- RadarBool res = False;
+ ZnReal tmp;
+ ZnBool res = False;
tmp = t->_[0][0] - 1.0;
res = res & ((tmp < PRECISION_LIMIT) && (tmp > -PRECISION_LIMIT));
@@ -186,22 +186,22 @@ RadarTransfoIsIdentity(RadarTransfo *t)
/*
*************************************************************************
*
- * RadarTransfoSetIdentity --
+ * ZnTransfoSetIdentity --
* Initialize the given transfo to identity.
*
*************************************************************************
*/
void
-RadarTransfoSetIdentity(RadarTransfo *t)
+ZnTransfoSetIdentity(ZnTransfo *t)
{
- *t = ((RadarTransfo) {{{1, 0}, {0, 1}, {0, 0}}});
+ *t = ((ZnTransfo) {{{1, 0}, {0, 1}, {0, 0}}});
}
/*
*************************************************************************
*
- * RadarTransfoCompose --
+ * ZnTransfoCompose --
* Combine two transformations t1 and t2 by post-concatenation.
* Returns the resulting transformation.
* t2 can be NULL, meaning identity transform. This is used in
@@ -211,13 +211,13 @@ RadarTransfoSetIdentity(RadarTransfo *t)
*
*************************************************************************
*/
-RadarTransfo *
-RadarTransfoCompose(RadarTransfo *res,
- RadarTransfo *t1,
- RadarTransfo *t2)
+ZnTransfo *
+ZnTransfoCompose(ZnTransfo *res,
+ ZnTransfo *t1,
+ ZnTransfo *t2)
{
if ((t1 != NULL) && (t2 != NULL)) {
- register RadarReal tmp;
+ register ZnReal tmp;
tmp = t1->_[0][0];
res->_[0][0] = tmp*t2->_[0][0] + t1->_[0][1]*t2->_[1][0];
@@ -240,7 +240,7 @@ RadarTransfoCompose(RadarTransfo *res,
}
}
else {
- RadarTransfoSetIdentity(res);
+ ZnTransfoSetIdentity(res);
}
return res;
@@ -250,7 +250,7 @@ RadarTransfoCompose(RadarTransfo *res,
/*
*************************************************************************
*
- * RadarTransfoInvert --
+ * ZnTransfoInvert --
* Compute the inverse of the given matrix and return it. This
* function makes the assumption that the matrix is affine to
* optimize the job. Do not give it a general matrix, this will
@@ -260,11 +260,11 @@ RadarTransfoCompose(RadarTransfo *res,
*
*************************************************************************
*/
-RadarTransfo *
-RadarTransfoInvert(RadarTransfo *t,
- RadarTransfo *inv)
+ZnTransfo *
+ZnTransfoInvert(ZnTransfo *t,
+ ZnTransfo *inv)
{
- RadarReal pos, neg, temp, det_l;
+ ZnReal pos, neg, temp, det_l;
if (t == NULL) {
return NULL;
@@ -293,7 +293,7 @@ RadarTransfoInvert(RadarTransfo *t,
temp = det_l / (pos - neg); /* Why divide by (pos - neg) ?? */
if (ABS(temp) < PRECISION_LIMIT) {
- RadarWarning("RadarTransfoInvert : singular matrix");
+ ZnWarning("ZnTransfoInvert : singular matrix");
return NULL;
}
@@ -319,7 +319,7 @@ RadarTransfoInvert(RadarTransfo *t,
/*
*************************************************************************
*
- * RadarTransfoDecompose --
+ * ZnTransfoDecompose --
* Decompose an affine matrix into translation, scale, shear and
* rotation. The different values are stored in the locations
* pointed to by the pointer parameters. If some values are not
@@ -330,14 +330,14 @@ RadarTransfoInvert(RadarTransfo *t,
*************************************************************************
*/
void
-RadarTransfoDecompose(RadarTransfo *t,
- RadarPoint *scale,
- RadarPoint *trans,
- RadarReal *rotation,
- RadarReal *shearxy)
+ZnTransfoDecompose(ZnTransfo *t,
+ ZnPoint *scale,
+ ZnPoint *trans,
+ ZnReal *rotation,
+ ZnReal *shearxy)
{
- RadarTransfo local;
- RadarReal shear, len, rot, det;
+ ZnTransfo local;
+ ZnReal shear, len, rot, det;
if (t == NULL) {
/* Identity transform */
@@ -361,12 +361,12 @@ RadarTransfoDecompose(RadarTransfo *t,
det = (t->_[0][0]*t->_[1][1] - t->_[0][1]*t->_[1][0]);
if (ABS(det) < PRECISION_LIMIT) {
- RadarWarning("RadarTransfoDecompose : singular matrix");
+ ZnWarning("ZnTransfoDecompose : singular matrix");
return;
}
local = *t;
- //RadarPrintTransfo(&local);
+ //ZnPrintTransfo(&local);
/* Get translation part if needed */
if (trans) {
trans->x = ABS(local._[2][0]) < PRECISION_LIMIT ? 0 : local._[2][0];
@@ -405,7 +405,7 @@ RadarTransfoDecompose(RadarTransfo *t,
//printf("shear %f\n", *shearxy);
}
//printf("Matrix after scale & shear extracted\n");
- //RadarPrintTransfo(&local);
+ //ZnPrintTransfo(&local);
/* Get rotation */
/* Check for a coordinate system flip. If det of upper-left 2x2
* is -1, there is a reflection. If the rotation is < 180° negate
@@ -444,17 +444,17 @@ RadarTransfoDecompose(RadarTransfo *t,
/*
*************************************************************************
*
- * RadarTransfoEqual --
+ * ZnTransfoEqual --
* Return True if t1 and t2 are equal (i.e they have the same
* rotation, shear scales and translations). If include_translation
* is True the translations are considered in the test.
*
*************************************************************************
*/
-RadarBool
-RadarTransfoEqual(RadarTransfo *t1,
- RadarTransfo *t2,
- RadarBool include_translation)
+ZnBool
+ZnTransfoEqual(ZnTransfo *t1,
+ ZnTransfo *t2,
+ ZnBool include_translation)
{
if (include_translation) {
return (t1->_[0][0] == t2->_[0][0] &&
@@ -476,14 +476,14 @@ RadarTransfoEqual(RadarTransfo *t1,
/*
*************************************************************************
*
- * RadarTransfoHasShear --
+ * ZnTransfoHasShear --
* Return True if t has a shear factor in x or y or describe a
* rotation or both.
*
*************************************************************************
*/
-RadarBool
-RadarTransfoHasShear(RadarTransfo *t)
+ZnBool
+ZnTransfoHasShear(ZnTransfo *t)
{
return t->_[0][1] != 0.0 || t->_[1][0] != 0.0;
}
@@ -492,13 +492,13 @@ RadarTransfoHasShear(RadarTransfo *t)
/*
*************************************************************************
*
- * RadarTransfoIsTranslation --
+ * ZnTransfoIsTranslation --
* Return True if t is a pure translation.
*
*************************************************************************
*/
-RadarBool
-RadarTransfoIsTranslation(RadarTransfo *t)
+ZnBool
+ZnTransfoIsTranslation(ZnTransfo *t)
{
return (t->_[0][0] == 0.0 &&
t->_[0][1] == 0.0 &&
@@ -510,7 +510,7 @@ RadarTransfoIsTranslation(RadarTransfo *t)
/*
*************************************************************************
*
- * RadarTransformPoint --
+ * ZnTransformPoint --
* Apply the transformation to the point. The point is
* modified and returned as the value of the function.
* A NULL transformation means identity. This is only used
@@ -519,10 +519,10 @@ RadarTransfoIsTranslation(RadarTransfo *t)
*
*************************************************************************
*/
-RadarPoint *
-RadarTransformPoint(RadarTransfo *t,
- register RadarPoint *p,
- RadarPoint *xp)
+ZnPoint *
+ZnTransformPoint(ZnTransfo *t,
+ register ZnPoint *p,
+ ZnPoint *xp)
{
if (t == NULL) {
xp->x = p->x;
@@ -539,7 +539,7 @@ RadarTransformPoint(RadarTransfo *t,
/*
*************************************************************************
*
- * RadarTransformPoints --
+ * ZnTransformPoints --
* Apply the transformation to the points in p returning points in xp.
* The number of points is in num.
* A NULL transformation means identity. This is only used
@@ -549,13 +549,13 @@ RadarTransformPoint(RadarTransfo *t,
*************************************************************************
*/
void
-RadarTransformPoints(RadarTransfo *t,
- RadarPoint *p,
- RadarPoint *xp,
- int num)
+ZnTransformPoints(ZnTransfo *t,
+ ZnPoint *p,
+ ZnPoint *xp,
+ int num)
{
if (t == NULL) {
- memcpy(xp, p, sizeof(RadarPoint)*num);
+ memcpy(xp, p, sizeof(ZnPoint)*num);
}
else {
int i;
@@ -571,20 +571,20 @@ RadarTransformPoints(RadarTransfo *t,
/*
*************************************************************************
*
- * RadarTranslate --
+ * ZnTranslate --
* Translate the given transformation by delta_x, delta_y. Returns
* the resulting transformation.
*
- * RadarSetTranslation --
+ * ZnSetTranslation --
* Set the translation instead of combining it into the
* transformation.
*
*************************************************************************
*/
-RadarTransfo *
-RadarTranslate(RadarTransfo *t,
- RadarReal delta_x,
- RadarReal delta_y)
+ZnTransfo *
+ZnTranslate(ZnTransfo *t,
+ ZnReal delta_x,
+ ZnReal delta_y)
{
t->_[2][0] = t->_[2][0] + delta_x;
t->_[2][1] = t->_[2][1] + delta_y;
@@ -592,10 +592,10 @@ RadarTranslate(RadarTransfo *t,
return t;
}
-RadarTransfo *
-RadarSetTranslation(RadarTransfo *t,
- RadarReal delta_x,
- RadarReal delta_y)
+ZnTransfo *
+ZnSetTranslation(ZnTransfo *t,
+ ZnReal delta_x,
+ ZnReal delta_y)
{
t->_[2][0] = delta_x;
t->_[2][1] = delta_y;
@@ -607,16 +607,16 @@ RadarSetTranslation(RadarTransfo *t,
/*
*************************************************************************
*
- * RadarScale --
+ * ZnScale --
* Scale the given transformation by scale_x, scale_y. Returns the
* resulting transformation.
*
*************************************************************************
*/
-RadarTransfo *
-RadarScale(RadarTransfo *t,
- register RadarReal scale_x,
- register RadarReal scale_y)
+ZnTransfo *
+ZnScale(ZnTransfo *t,
+ register ZnReal scale_x,
+ register ZnReal scale_y)
{
t->_[0][0] = t->_[0][0]*scale_x;
t->_[0][1] = t->_[0][1]*scale_y;
@@ -632,20 +632,20 @@ RadarScale(RadarTransfo *t,
/*
*************************************************************************
*
- * RadarRotateRad --
+ * ZnRotateRad --
* Rotate the given transformation by angle radians
* counter-clockwise around the origin. Returns the resulting
* transformation.
*
*************************************************************************
*/
-RadarTransfo *
-RadarRotateRad(RadarTransfo *t,
- RadarReal angle)
+ZnTransfo *
+ZnRotateRad(ZnTransfo *t,
+ ZnReal angle)
{
- register RadarReal c = cos(angle);
- register RadarReal s = sin(angle);
- register RadarReal tmp;
+ register ZnReal c = cos(angle);
+ register ZnReal s = sin(angle);
+ register ZnReal tmp;
tmp = t->_[0][0];
t->_[0][0] = tmp*c - t->_[0][1]*s;
@@ -664,18 +664,18 @@ RadarRotateRad(RadarTransfo *t,
/*
*************************************************************************
*
- * RadarRotateDeg --
+ * ZnRotateDeg --
* Rotate the given transformation by angle degrees
* counter-clockwise around the origin. Returns the resulting
* transformation.
*
*************************************************************************
*/
-RadarTransfo *
-RadarRotateDeg(RadarTransfo *t,
- RadarReal angle)
+ZnTransfo *
+ZnRotateDeg(ZnTransfo *t,
+ ZnReal angle)
{
- return RadarRotateRad(t, DegreesToRadian(angle));
+ return ZnRotateRad(t, DegreesToRadian(angle));
}