




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、空間直角坐標(biāo)轉(zhuǎn)換之仿射變換一、仿射變換仿射變換是空間直角坐標(biāo)變換的一種,它是一種二維坐標(biāo)到二維坐標(biāo)之間的線性變換,保持二維圖形的“平直線”和“平行性",其可以通過一系列的原子變換的復(fù)合來實現(xiàn),包括平移(Translation)、縮放(Scale)、翻轉(zhuǎn)(Flip)、旋轉(zhuǎn)(Rotation)和剪切(Shear)。此類變換可以用一個3×3的矩陣來表示,其最后一行為(0, 0, 1).該變換矩陣將原坐標(biāo)(x, y)變換為新坐標(biāo)(x, y'),這里原坐標(biāo)和新坐標(biāo)皆視為最末一行為(1)的三維列向量,原列向量左乘變換矩陣得到新的列向量:x' m00 m01 m02 x
2、m00x+m01y+m02y' = m10 m11 m12 y = m10x+m11*y+m121 0 0 1 1 1 如果將它寫成按旋轉(zhuǎn)、縮放、平移三個分量的復(fù)合形式,則其代數(shù)式如下: x' = m00x+m01y+m02; y = m10x+m11*y+m12;其示意圖如下:幾種典型的仿射變換:1.public static AffineTransform getTranslateInstance(double tx, double ty) 平移變換,將每一點移動到(x+tx, y+ty),變換矩陣為: 1 0 tx 0 1 ty 0 0 1 (譯注:平移變換是一種“剛體變
3、換”,rigidbody transformation,中學(xué)學(xué)過的物理,都知道啥叫“剛體"吧,就是不會產(chǎn)生形變的理想物體,平移當(dāng)然不會改變二維圖形的形狀.同理,下面的“旋轉(zhuǎn)變換”也是剛體變換,而“縮放”、“錯切”都是會改變圖形形狀的。) 2.public static AffineTransform getScaleInstance(double sx, double sy) 縮放變換,將每一點的橫坐標(biāo)放大(縮?。┲羢x倍,縱坐標(biāo)放大(縮小)至sy倍,變換矩陣為: sx 0 0 0 sy 0 0 0 1 3.public static AffineTransform getShear
4、Instance(double shx, double shy) 剪切變換,變換矩陣為: 1 shx 0 shy 1 0 0 0 1 相當(dāng)于一個橫向剪切與一個縱向剪切的復(fù)合 1 0 0 1 shx 0 shy 1 0 0 1 0 0 0 1 0 0 1 (譯注:“剪切變換”又稱“錯切變換",指的是類似于四邊形不穩(wěn)定性那種性質(zhì),街邊小商店那種鐵拉門都見過吧?想象一下上面鐵條構(gòu)成的菱形拉動的過程,那就是“錯切”的過程。) 4。public static AffineTransform getRotateInstance(double theta) 旋轉(zhuǎn)變換,目標(biāo)圖形圍繞原點順時針旋轉(zhuǎn)th
5、eta弧度,變換矩陣為: cos(theta) -sin(theta) 0 sin(theta) cos(theta) 0 0 0 1 5.public static AffineTransform getRotateInstance(double theta, double x, double y) 旋轉(zhuǎn)變換,目標(biāo)圖形以(x, y)為軸心順時針旋轉(zhuǎn)theta弧度,變換矩陣為: cos(theta) sin(theta) xx*cos+y*sin sin(theta) cos(theta) y-x*sin-y*cos 0 0 1 相當(dāng)于兩次平移變換與一次原點旋轉(zhuǎn)變換的復(fù)合:1 0 -xcos(
6、theta) sin(theta) 01 0 x0 1 -ysin(theta) cos(theta) 00 1 y0 0 1 0 0 1 0 0 1二、仿射變換四參數(shù)求解A、C自定義函數(shù)實現(xiàn)求解:1、求解旋轉(zhuǎn)參數(shù)Rotaion: 1/<summary 2 3 /獲取旋轉(zhuǎn)角度 4 5 /summary> 6 7
7、60; /<param name="fromCoordPoint1"源點1</param> 8 9 /param name=”toCoordPoint1">目標(biāo)點1/param>1011 /<param name=”fromC
8、oordPoint2">源點2</param1213 /<param name="toCoordPoint2">目標(biāo)點2/param1415 /<returns>返回旋轉(zhuǎn)角度</returns>1617 private
9、double GetRotation(CoordPoint fromPoint1, CoordPoint toPoint1,CoordPoint fromPoint2,CoordPoint toPoint2)1819 2021 double a = (toPoint2.Y&
10、#160; toPoint1.Y) (fromPoint2.X - fromPoint1.X) (toPoint2。X - toPoint1。X) * (fromPoint2。Y - fromPoint1.Y);2223 double b = (toPoint2。X - t
11、oPoint1。X) (fromPoint2。X - fromPoint1。X) + (toPoint2.Y toPoint1。Y) (fromPoint2。Y fromPoint1.Y);2425 2627 &
12、#160; if (Math.Abs(b) 0)2829 return Math。Tan(a / b);3031 else3233
13、60; return Math.Tan(0); 3435 文檔為個人收集整理,來源于網(wǎng)絡(luò)文檔為個人收集整理,來源于網(wǎng)絡(luò)2、求解縮放比例參數(shù)(Scale): 1 /*/<summary 2 3
14、 /獲取縮放比例因子 4 5 /summary 6 7 /param name=”fromCoordPoint1”源點1/param 8 9 /<p
15、aram name="toCoordPoint1"目標(biāo)點1</param>1011 /param name="fromCoordPoint2”源點2</param>1213 /<param name="toCoordPoint2”>目標(biāo)點2/param1415
16、; /<param name="rotation”旋轉(zhuǎn)角度</param>1617 /returns>返回旋轉(zhuǎn)因子</returns>1819 private double GetScale(CoordPoint fromPoint1, CoordPoint
17、toPoint1, CoordPoint fromPoint2, CoordPoint toPoint2, double rotation)2021 2223 double a = toPoint2.X toPoint1.X;2425
18、60; double b = (fromPoint2.X - fromPoint1。X) * Math。Cos(rotation) (fromPoint2.Y fromPoint1.Y)Math。Sin(rotation);2627
19、160;if (Math.Abs(b) > 0)2829 return a / b;3031 else3233
20、0; return 0;3435 本文為互聯(lián)網(wǎng)收集,請勿用作商業(yè)用途文檔為個人收集整理,來源于網(wǎng)絡(luò)3、求解X方向偏移距離參數(shù)(XTranslate): 1/*/summary 2 3 /得到X方向偏移量 4 5 /summary> 6 7 /<param name="fromCoordPoint1”>源點1/param> 8 9 /param name="
21、toCoordPoint1”目標(biāo)點1/param>1011 /<param name=”rotation”>旋轉(zhuǎn)角度/param1213 /<param name=”scale"縮放因子</param1415 /<returns返回X方向偏移量/returns>1617 private double GetXTranslation(CoordPoint fromPoint1,CoordPoint toPoint1,double rotation,double scale)1819 2021 return (toPoint1.X - scale
22、 (fromPoint1。X * Math.Cos(rotation) fromPoint1.Y Math。Sin(rotation)));2223 2425 4、求解Y方向偏移距離參數(shù)(YTranslate): 1 /*/summary> 2 3 /得到Y(jié)方向偏移量 4 5 /</summary 6 7 /<param name="fromCoordPoint1”源點1/param> 8 9 /param name="toCoordPoint1">目標(biāo)點1/param1011 /param name=”rotation”>旋轉(zhuǎn)
23、角度</param>1213 /param name=”scale">縮放因子/param1415 /<returns>返回Y方向偏移量</returns1617 private double GetYTranslation(CoordPoint fromPoint1, CoordPoint toPoint1, double rotation, double scale)1819 2021 return (toPoint1.Y scale * (fromPoint1.X * Math.Sin(rotation) + fromPoint1.Y * M
24、ath。Cos(rotation));2223 B、C+AE求解: 1/*/<summary> 2 3 /從控制點定義仿射變換程式 4 5 /summary 6 7 /<param name=”p
25、FromPoints”>源控制點</param 8 9 /<param name=”pToPoints">目標(biāo)控制點/param1011 /returns返回變換定義</returns1213 private ITransformatio
26、n GetAffineTransformation(IPoint pFromPoints, IPoint pToPoints)1415 1617 /實例化仿射變換對象1819 IAf
27、fineTransformation2D3GEN tAffineTransformation = new AffineTransformation2DClass();2021 /從源控制點定義參數(shù)2223 tAffineTransformation.DefineFromCon
28、trolPoints(ref pFromPoints, ref pToPoints);2425 /查詢引用接口2627 ITransformation tTransformation = tAffineTransformation as
29、;ITransformation;2829 return tTransformation;3031 個人收集整理,勿做商業(yè)用途本文為互聯(lián)網(wǎng)收集,請勿用作商業(yè)用途 三、空間對象轉(zhuǎn)換 求出參數(shù)后,再利用公式對相應(yīng)坐標(biāo)點進(jìn)行轉(zhuǎn)換是一件相對簡單的事件了。示例代碼: /<summary 2 3
30、 /轉(zhuǎn)換空間點 4 5 /summary 6 7 /param name="pPoint”>點</param> 8 9 /returns&
31、gt;返回轉(zhuǎn)換后的點/returns1011 private IGeometry TransformPoint(IPoint pPoint)1213 1415 /*1617
32、0; /說明:采用相似變換模型(四參數(shù)變換模型)1819 / X= ax + by + c2021 / Y=-bx + ay + d2223 /*2425
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 銀行從業(yè)資格證考試2025年知識點梳理試題及答案
- 2025年國際金融理財師考試知識點學(xué)習(xí)方法試題及答案
- 模具畜牧師考試記憶試題及答案
- 銀行海外業(yè)務(wù)的開展模式試題及答案
- 潮南區(qū)模擬考試卷及答案
- 滄州吳橋縣中考試卷及答案
- 韻達(dá)快遞員工培訓(xùn)計劃
- 末道考驗2024年小語種證書考試試題及答案
- 網(wǎng)絡(luò)編輯師證書考試通關(guān)秘笈試題及答案
- 2024年網(wǎng)絡(luò)編輯師證書考試建議與試題及答案
- 2024-2025班主任的培訓(xùn)心得體會(29篇)
- 實驗14 探究液體內(nèi)部壓強的特點-中考物理必考實驗專項復(fù)習(xí)
- 7 請到我的家鄉(xiāng)來(第一課時)(教學(xué)設(shè)計)統(tǒng)編版道德與法治三年級下冊
- 護(hù)理不良事件案例分析及警示
- B超健康知識講座課件
- 煤炭倉儲協(xié)議合同
- 政 治薪火相傳的傳統(tǒng)美德 教案-2024-2025學(xué)年統(tǒng)編版道德與法治七年級下冊
- 3.1偉大的改革開放+課件高中政治統(tǒng)編版必修一中國特色社會主義
- 2025屆山東省濟(jì)南市高三下學(xué)期一模英語試題(原卷版+解析版)
- 2025年(四川)公需科目(心理健康與職業(yè)發(fā)展主題)題庫及答案
- 肺功能課件完整版本
評論
0/150
提交評論