00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 using System;
00053 using System.Drawing;
00054
00055 namespace NPlot
00056 {
00057
00062 public class Transform2D
00063 {
00064
00071 public static ITransform2D GetTransformer( PhysicalAxis xAxis, PhysicalAxis yAxis )
00072 {
00073 ITransform2D ret = null;
00074
00075
00076
00077
00078
00079
00080 ret = new DefaultTransform2D( xAxis, yAxis );
00081
00082 return ret;
00083 }
00084
00085
00089 public class DefaultTransform2D : ITransform2D
00090 {
00091 private PhysicalAxis xAxis_;
00092 private PhysicalAxis yAxis_;
00093
00099 public DefaultTransform2D( PhysicalAxis xAxis, PhysicalAxis yAxis )
00100 {
00101 xAxis_ = xAxis;
00102 yAxis_ = yAxis;
00103 }
00104
00105
00112 public PointF Transform( double x, double y )
00113 {
00114 return new PointF(
00115 xAxis_.WorldToPhysical( x, true ).X,
00116 yAxis_.WorldToPhysical( y, true ).Y );
00117 }
00118
00119
00125 public PointF Transform( PointD worldPoint )
00126 {
00127 return new PointF(
00128 xAxis_.WorldToPhysical( worldPoint.X, true ).X,
00129 yAxis_.WorldToPhysical( worldPoint.Y, true ).Y );
00130 }
00131
00132 }
00133
00134
00135
00136
00141 public class FastTransform2D : ITransform2D
00142 {
00143
00144 private PageAlignedPhysicalAxis xAxis_;
00145 private PageAlignedPhysicalAxis yAxis_;
00146
00147
00153 public FastTransform2D( PhysicalAxis xAxis, PhysicalAxis yAxis )
00154 {
00155 xAxis_ = new PageAlignedPhysicalAxis( xAxis );
00156 yAxis_ = new PageAlignedPhysicalAxis( yAxis );
00157 }
00158
00159
00166 public PointF Transform( double x, double y )
00167 {
00168 return new PointF(
00169 xAxis_.WorldToPhysicalClipped( x ),
00170 yAxis_.WorldToPhysicalClipped( y ) );
00171 }
00172
00173
00179 public PointF Transform( PointD worldPoint )
00180 {
00181 return new PointF(
00182 xAxis_.WorldToPhysical( worldPoint.X ),
00183 yAxis_.WorldToPhysical( worldPoint.Y ) );
00184 }
00185
00186 }
00187
00188
00189 }
00190 }