summaryrefslogtreecommitdiff
path: root/dviware/umddvi/lib/conv.c
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /dviware/umddvi/lib/conv.c
Initial commit
Diffstat (limited to 'dviware/umddvi/lib/conv.c')
-rw-r--r--dviware/umddvi/lib/conv.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/dviware/umddvi/lib/conv.c b/dviware/umddvi/lib/conv.c
new file mode 100644
index 0000000000..91f2088cda
--- /dev/null
+++ b/dviware/umddvi/lib/conv.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 1987 University of Maryland Department of Computer Science.
+ * All rights reserved. Permission to copy for any purpose is hereby granted
+ * so long as this copyright notice remains intact.
+ */
+
+#ifndef lint
+static char rcsid[] = "$Header: conv.c,v 1.3 87/06/16 18:27:39 chris Exp $";
+#endif
+
+/*
+ * Conversions.
+ */
+
+#include "types.h"
+#include "conv.h"
+
+double DMagFactor();
+
+/*
+ * Set a conversion (possibly the global conversion).
+ */
+void
+CSetConversion(c, dpi, usermag, num, denom, dvimag)
+ register struct conversion *c;
+ int dpi, usermag;
+ i32 num, denom, dvimag;
+{
+ double ddpi = dpi;
+
+ c->c_mag = DMagFactor((int) dvimag) * DMagFactor(usermag);
+ c->c_dpi = ddpi;
+
+ /*
+ * The conversion facture is figured as follows: there are exactly
+ * num/denom DVI units per decimicron, and 254000 decimicrons per
+ * inch, and dpi pixels per inch. Then we have to adjust this by
+ * the stated magnification.
+ */
+ c->c_fromsp = (num / 254000.0) * (ddpi / denom) * c->c_mag;
+
+ /*
+ * c->c_tosp is 1/c->c_fromsp, but we will invert the expression
+ * above in the hopes of some extra accuracy.
+ *
+ * IS THIS ANY GOOD? I NEED A NUMERICAL ANALYST!
+ */
+ c->c_tosp = (254000.0 / num) * (denom / ddpi) * (1.0 / c->c_mag);
+}