首页 新闻 会员 周边 捐助

坐标变换 多个坐标系的转换问题

0
悬赏园豆:80 [已关闭问题] 关闭于 2013-09-16 10:05
 1 namespace CoordinateClass
 2 {
 3     class PhysicalCoordinate
 4     {
 5         public double X;
 6         public double Y;
 7 
 8         public struct TransCoordinate
 9         {
10             public double XGain_Print; //转换的线性关系 ,PrintCoordinate.X=this.X*XGain_Print+XOffset_Print; 转换为打印的坐标
11             public double XOffset_Print;
12 
13             public double YGain_Print;
14             public double YOffset_Print;
15 
16             public double XGain_Image;//转换图像坐标的增益零点
17             public double XOffset_Inage;
18 
19             public double YGain_Image;
20             public double YOffset_Image;
21 
22             public double XGain_CCDCenter;//转换为CCD中心坐标的增益零点
23             public double XOffset_CCDCenter;
24 
25             public double YGain_CCDCenter;
26             public double YOffset_CCDCenter;
27         }
28         public static TransCoordinate transCooridnate;
29         public PhysicalCoordinate(PhysicalCoordinate coordinate)
30         {
31             this.X = coordinate.X;
32             this.Y = coordinate.Y;
33         }
34        public PhysicalCoordinate(double x, double y)
35         {
36             this.X = x;
37             this.Y = y;
38         }
39        public PhysicalCoordinate()
40         {
41             this.X = 0;
42             this.Y = 0;
43         }
44         public PrintCoordinate ToPrintCoordinate() ///当前点转换为打印坐标系中的点
45         {
46             double tempX = X * transCooridnate.XGain_Print + transCooridnate.XOffset_Print;
47             double tempY = Y * transCooridnate.XGain_Print + transCooridnate.YOffset_Print;
48             PrintCoordinate PCooridnate = new PrintCoordinate(tempX, tempY);
49             return PCooridnate;
50         }
51 
52         public ImageCoordinate ToImageCoordinate() //当前点转换为图像坐标系中对应的点
53         {
54             return new ImageCoordinate();
55         }
56 
57         public CCDCenterCoordinate ToCCDCenterCoordinate()//转换为CCD坐标
58         {
59             return new CCDCenterCoordinate();
60         }
61 
62         public static PhysicalCoordinate operator +(PhysicalCoordinate coordinate1, PhysicalCoordinate coordinate2)
63         {
64             return new PhysicalCoordinate(coordinate2.X + coordinate1.X, coordinate2.Y + coordinate1.Y);//操作符重载
65         }
66 
67         public static PhysicalCoordinate operator -(PhysicalCoordinate coordinate1, PhysicalCoordinate coordinate2)
68         {
69             return new PhysicalCoordinate(coordinate1.X - coordinate2.X, coordinate1.Y - coordinate2.Y);//操作符重载
70         }
71 
72         /// <summary>
73         /// 判断两个坐标是否相等
74         /// </summary>
75         /// <param name="coordinate1">第一个坐标</param>
76         /// <param name="coordinate2">第二个坐标</param>
77         /// <param name="reterminPointBit">保留的小数位</param>
78         /// <returns></returns>
79         public static bool Equale(PhysicalCoordinate coordinate1, PhysicalCoordinate coordinate2,int reterminPointBit=0)
80         {
81             return true;
82         }
83 
84         public double GetDistanceBetweenPoint(PhysicalCoordinate coordinate)
85         {
86             return Math.Sqrt(Math.Pow(Math.Abs(this.X - coordinate.X), 2) + Math.Pow(Math.Abs(this.Y - coordinate.Y), 2));
87         }
88     }
89 }

共有四个坐标系,一个运动坐标系即PhysicCoordinate,打印坐标系PrintCoordinate 图像坐标系ImageCoordinage CCD坐标系CCDCenterCoordinate,现在的需求是如何实现这几个坐标系互相转换。如何用面向对象的方式去实现这几个坐标系互相转换。用继承或者泛型或者接口的方式,或者更好的方式实现。
PhysicalCoordinate.ToImageCoordinate()//运动坐标系中的点转换为图像坐标系中的点

PhysicalCoordinate.ToPrintCoordinate()//运动坐标系中的点转换为打印坐标系中的点

ImageCoordinate.ToPrintCoordinate()//图像坐标系中的点转换为打印坐标系中的点

转换的关系式:ToImageCoordinate.X=PhysicalCoordinate.X*K+B; 其中K,B为double类型的变量。对应结构体中的TransCoordinate.XGain_Image(增益值),TransCoordinate.XOffset_Image(零点值)

赤血红尘的主页 赤血红尘 | 初学一级 | 园豆:116
提问于:2013-09-10 13:04
< >
分享
所有回答(1)
0

哇塞,不懂啊。能不能用文字描述,看着晕,呵呵

会长 | 园豆:12463 (专家六级) | 2013-09-10 17:34
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册