随笔 - 934, 文章 - 0, 评论 - 249, 阅读 - 345万

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

坐标系的转换

Posted on   蝈蝈俊  阅读(4600)  评论(0编辑  收藏  举报

如下图,我们会有下面的需求,在坐标系1中,绘出一个图像, 这个图形自身的坐标系是2, 它里面又绘出了3个图形自身坐标系的一些东西。

image

这个变化过程如下图, 通过一个个的仿射变换矩阵完成变化。

image

 

一些相关基础知识:

矩阵乘法

2*2 矩阵 互相乘

image

 

 

image

 

image

参考:
http://taop.marchtea.com/02.08.html

简单来说,第一个矩阵取行, 第二个矩阵取列, 然后交叉相乘的和。

image

 

 

三角函数

image

常见三角函数的值:

image

 

平面直角坐标系及其变换

image

自身坐标系与参考坐标系

在一部分计算机 2D 绘图技术中,每个绘图元素会有自己的一个坐标系,称为「自身坐标系」。当图形 A 放作为图形 B 的一个元素的时候,可以把图形 B 的自身坐标系作为图形 A 的参考坐标系。

image

image

这个矩阵称为「二维线性变换矩阵」,记为 M。

矩阵的默认值如下, 该取值时是无变换的。因为  X` = X        Y`=Y

image

参考: 2D 绘图技术中的坐标系统与坐标变换
http://fex.baidu.com/blog/2014/05/coordinate-and-transform/

 

 

 

而坐标转换的矩阵我们一般如下(下面来自Windows的 GDI+ 编程的资料):

image

image

 

 

类似的在 HTML5 的 Canvas 接口文档中也有类似的,如下图:

HTML5 mozilla Canvas API Transform 相关资料
https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations

image

 

 

参考:

坐标系统与坐标变换 PPT
https://speakerdeck.com/baidufe/2d-hui-tu-zhong-de-zuo-biao-xi-tong-he-zuo-biao-bian-huan

SVG中的坐标系统和坐标变换
https://segmentfault.com/a/1190000004320934

http://blog.sina.com.cn/s/blog_5f38c0560100uzrj.html

https://segmentfault.com/a/1190000004469449

 


JDK 1.2 版本中就有类似的方法

参考: http://udn.yyuap.com/doc/jdk6-api-zh/java/awt/geom/AffineTransform.html

image

 

image

 

image

参考:

http://stackoverflow.com/questions/21503595/what-are-the-maths-behind-3d-billboard-sprites-was-3d-transformation-matrix-t

 

 

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Transforms/Transforms.html

 

组合的坐标系变化例子:

image

image

参考:

https://www.cs.auckland.ac.nz/courses/compsci773s1c/lectures/ImageProcessing-html/topic2.htm

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示
历史上的今天:
2013-02-25 Go语言的struct tag
点击右上角即可分享
微信分享提示