Back to index

plt-scheme  4.2.1
plcvt.c
Go to the documentation of this file.
00001 /* $Id: plcvt.c,v 1.1 2004/03/01 20:54:51 cozmic Exp $
00002 
00003        Coordinate transformation routines.
00004 */
00005 
00006 #include "plplotP.h"
00007 
00008 /*--------------------------------------------------------------------------*\
00009  * Transformations returning physical coordinates.
00010 \*--------------------------------------------------------------------------*/
00011 
00012 /* device coords to physical coords (x) */
00013 
00014 PLINT
00015 plP_dcpcx(PLFLT x)
00016 {
00017     return (ROUND(plsc->phyxmi + plsc->phyxlen * x));
00018 }
00019 
00020 /* device coords to physical coords (y) */
00021 
00022 PLINT
00023 plP_dcpcy(PLFLT y)
00024 {
00025     return (ROUND(plsc->phyymi + plsc->phyylen * y));
00026 }
00027 
00028 /* millimeters from bottom left-hand corner to physical coords (x) */
00029 
00030 PLINT
00031 plP_mmpcx(PLFLT x)
00032 {
00033     return (ROUND(plsc->phyxmi + plsc->xpmm * x));
00034 }
00035 
00036 /* millimeters from bottom left-hand corner to physical coords (y) */
00037 
00038 PLINT
00039 plP_mmpcy(PLFLT y)
00040 {
00041     return (ROUND(plsc->phyymi + plsc->ypmm * y));
00042 }
00043 
00044 /* world coords to physical coords (x) */
00045 
00046 PLINT
00047 plP_wcpcx(PLFLT x)
00048 {
00049     return (ROUND(plsc->wpxoff + plsc->wpxscl * x));
00050 }
00051 
00052 /* world coords to physical coords (y) */
00053 
00054 PLINT
00055 plP_wcpcy(PLFLT y)
00056 {
00057     return (ROUND(plsc->wpyoff + plsc->wpyscl * y));
00058 }
00059 
00060 /*--------------------------------------------------------------------------*\
00061  * Transformations returning device coordinates.
00062 \*--------------------------------------------------------------------------*/
00063 
00064 /* physical coords to device coords (x) */
00065 
00066 PLFLT
00067 plP_pcdcx(PLINT x)
00068 {
00069     return (PLFLT) ((x - plsc->phyxmi) / (double) plsc->phyxlen);
00070 }
00071 
00072 /* physical coords to device coords (y) */
00073 
00074 PLFLT
00075 plP_pcdcy(PLINT y)
00076 {
00077     return (PLFLT) ((y - plsc->phyymi) / (double) plsc->phyylen);
00078 }
00079 
00080 /* millimeters from bottom left corner to device coords (x) */
00081 
00082 PLFLT
00083 plP_mmdcx(PLFLT x)
00084 {
00085     return ((PLFLT) (x * plsc->xpmm / ABS(plsc->phyxma - plsc->phyxmi)));
00086 }
00087 
00088 /* millimeters from bottom left corner to device coords (y) */
00089 
00090 PLFLT
00091 plP_mmdcy(PLFLT y)
00092 {
00093     return ((PLFLT) (y * plsc->ypmm / ABS(plsc->phyyma - plsc->phyymi)));
00094 }
00095 
00096 /* world coords into device coords (x) */
00097 
00098 PLFLT
00099 plP_wcdcx(PLFLT x)
00100 {
00101     return ((PLFLT) (plsc->wdxoff + plsc->wdxscl * x));
00102 }
00103 
00104 /* world coords into device coords (y) */
00105 
00106 PLFLT
00107 plP_wcdcy(PLFLT y)
00108 {
00109     return ((PLFLT) (plsc->wdyoff + plsc->wdyscl * y));
00110 }
00111 
00112 /* subpage coords to device coords (x) */
00113 
00114 PLFLT
00115 plP_scdcx(PLFLT x)
00116 {
00117     return ((PLFLT) (plsc->spdxmi + (plsc->spdxma - plsc->spdxmi) * x));
00118 }
00119 
00120 /* subpage coords to device coords (y) */
00121 
00122 PLFLT
00123 plP_scdcy(PLFLT y)
00124 {
00125     return ((PLFLT) (plsc->spdymi + (plsc->spdyma - plsc->spdymi) * y));
00126 }
00127 
00128 /*--------------------------------------------------------------------------*\
00129  * Transformations returning millimeters.
00130 \*--------------------------------------------------------------------------*/
00131 
00132 /* device coords to millimeters from bottom left-hand corner (x) */
00133 
00134 PLFLT
00135 plP_dcmmx(PLFLT x)
00136 {
00137     return ((PLFLT) (x * ABS(plsc->phyxma - plsc->phyxmi) / plsc->xpmm));
00138 }
00139 
00140 /* device coords to millimeters from bottom left-hand corner (y) */
00141 
00142 PLFLT
00143 plP_dcmmy(PLFLT y)
00144 {
00145     return ((PLFLT) (y * ABS(plsc->phyyma - plsc->phyymi) / plsc->ypmm));
00146 }
00147 
00148 /* world coords into millimeters (x) */
00149 
00150 PLFLT
00151 plP_wcmmx(PLFLT x)
00152 {
00153     return ((PLFLT) (plsc->wmxoff + plsc->wmxscl * x));
00154 }
00155 
00156 /* world coords into millimeters (y) */
00157 
00158 PLFLT
00159 plP_wcmmy(PLFLT y)
00160 {
00161     return ((PLFLT) (plsc->wmyoff + plsc->wmyscl * y));
00162 }
00163 
00164 /*--------------------------------------------------------------------------*\
00165  * Transformations returning subpage coordinates.
00166 \*--------------------------------------------------------------------------*/
00167 
00168 /* device coords to subpage coords (x) */
00169 
00170 PLFLT
00171 plP_dcscx(PLFLT x)
00172 {
00173     return ((PLFLT) ((x - plsc->spdxmi) / (plsc->spdxma - plsc->spdxmi)));
00174 }
00175 
00176 /* device coords to subpage coords (y) */
00177 
00178 PLFLT
00179 plP_dcscy(PLFLT y)
00180 {
00181     return ((PLFLT) ((y - plsc->spdymi) / (plsc->spdyma - plsc->spdymi)));
00182 }
00183 
00184 /*--------------------------------------------------------------------------*\
00185  * 3-d plot transformations.
00186 \*--------------------------------------------------------------------------*/
00187 
00188 /* 3-d coords to 2-d projection (x) */
00189 
00190 PLFLT
00191 plP_w3wcx(PLFLT x, PLFLT y, PLFLT z)
00192 {
00193     return ((PLFLT) ((x - plsc->basecx) * plsc->cxx +
00194                    (y - plsc->basecy) * plsc->cxy));
00195 }
00196 
00197 /* 3-d coords to 2-d projection (y) */
00198 
00199 PLFLT
00200 plP_w3wcy(PLFLT x, PLFLT y, PLFLT z)
00201 {
00202     return ((PLFLT) ((x - plsc->basecx) * plsc->cyx +
00203                    (y - plsc->basecy) * plsc->cyy +
00204                    (z - plsc->ranmi) * plsc->cyz));
00205 }