在OpenCADCADE中, 通过gp_Trsf类来进行矩阵变换操作,

采用矩阵在左的方式: 新点 = 变换矩阵 * 点

基本原理如下:

//! Defines a non-persistent transformation in 3D space.
//! The following transformations are implemented :
//! . Translation, Rotation, Scale
//! . Symmetry with respect to a point, a line, a plane.
//! Complex transformations can be obtained by combining the
//! previous elementary transformations using the method
//! Multiply.
//! The transformations can be represented as follow :
//!
//! V1 V2 V3 T XYZ XYZ
//! | a11 a12 a13 a14 | | x | | x'|
//! | a21 a22 a23 a24 | | y | | y'|
//! | a31 a32 a33 a34 | | z | = | z'|
//! | 0 0 0 1 | | 1 | | 1 |
//!
//! where {V1, V2, V3} defines the vectorial part of the
//! transformation and T defines the translation part of the
//! transformation.
//! This transformation never change the nature of the objects.

  gp_Trsf定义了单个平移, 旋转, 缩放, 对称等操作

复杂变换: 需要通过 gp_Trsf乘法来实现, 如:

  一个物体要经过 缩放, 旋转, 平移等一系列操作时, 必须定义为

  平移 * 旋转 * 缩放

Python示例:

#!/usr/bin/env python
# -*- coding:utf-8 -*- import math
from OCC.gp import (gp_Pnt2d, gp_Vec2d, gp_Pnt, gp_Vec,
gp_Ax1, gp_OX, gp_OY, gp_OZ,
gp_Trsf) atranslation = gp_Trsf()
atranslation.SetTranslation(gp_Vec(1, 1, 1)) arotate = gp_Trsf()
arotate.SetRotation(gp_OZ(), math.pi) atransform = atranslation * arotate def test1():
print('测试1, 平移 -> 旋转')
pt = gp_Pnt(-1, -1, -1)
print(pt.Coord())
pt2 = pt.Transform(atranslation)
print(pt.Coord())
pt2 = pt.Transform(arotate)
print(pt.Coord()) def test2():
print('测试2, 平移 * 旋转')
pt = gp_Pnt(-1, -1, -1)
print(pt.Coord())
pt2 = pt.Transform(atranslation * arotate)
print(pt.Coord()) def test3():
print('测试3, 旋转 -> 平移')
pt = gp_Pnt(-1, -1, -1)
print(pt.Coord())
pt2 = pt.Transform(arotate)
print(pt.Coord())
pt2 = pt.Transform(atranslation)
print(pt.Coord()) def test4():
print('测试4, 旋转 * 平移')
pt = gp_Pnt(-1, -1, -1)
print(pt.Coord())
pt2 = pt.Transform(arotate * atranslation)
print(pt.Coord()) if __name__ == '__main__':
test1()
test2()
test3()
test4()
输出结果为:
测试1, 平移 -> 旋转
(-1.0, -1.0, -1.0)
(0.0, 0.0, 0.0)
(0.0, 0.0, 0.0)
测试2, 平移 * 旋转
(-1.0, -1.0, -1.0)
(2.0, 2.0, 0.0)
测试3, 旋转 -> 平移
(-1.0, -1.0, -1.0)
(1.0000000000000002, 0.9999999999999999, -1.0)
(2.0, 2.0, 0.0)
测试4, 旋转 * 平移
(-1.0, -1.0, -1.0)
(0.0, 0.0, 0.0)

OCC 矩阵变换的更多相关文章

  1. osg矩阵变换节点-----平移旋转缩放

    osg矩阵变换节点-----平移旋转缩放 转自:http://www.cnblogs.com/ylwn817/articles/1973396.html 平移旋转缩放这个三个是osg矩阵操作中,最常见 ...

  2. occ代码分析

    临时变量就是local里面的变量擦除变量就是把模型改成擦除标记 void SelectMgr_SelectionManager::LoadMode (const Handle(SelectMgr_Se ...

  3. OpenGL 矩阵变换

    Overview 几何数据--顶点位置,和标准向量(normal vectors),在OpenGL 管道raterization 处理过程之前可通过顶点操作(Vertex Operation)和基本组 ...

  4. 二维图形的矩阵变换(三)——在WPF中的应用矩阵变换

    原文:二维图形的矩阵变换(三)--在WPF中的应用矩阵变换 UIElement和RenderTransform 首先,我们来看看什么样的对象可以进行变换.在WPF中,用于呈现给用户的对象的基类为Vis ...

  5. 二维图形的矩阵变换(二)——WPF中的矩阵变换基础

    原文:二维图形的矩阵变换(二)--WPF中的矩阵变换基础 在前文二维图形的矩阵变换(一)——基本概念中已经介绍过二维图像矩阵变换的一些基础知识,本文中主要介绍一下如何在WPF中进行矩阵变换. Matr ...

  6. hdu 5671 矩阵变换

    Matrix Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Su ...

  7. 从UIImage的矩阵变换看矩阵运算的原理

    1.矩阵的基本知识: struct CGAffineTransform {  CGFloat a, b, c, d;  CGFloat tx, ty;}; CGAffineTransform CGAf ...

  8. VS2012下基于Glut 矩阵变换示例程序:

    也可以使用我们自己的矩阵运算来实现OpenGL下的glTranslatef相应的旋转变换.需要注意的是OpenGL下的矩阵是列优先存储的. 示例通过矩阵运算使得圆柱或者甜圈自动绕Y轴旋转,可以单击鼠标 ...

  9. VS2012下基于Glut 矩阵变换示例程序2:

    在VS2012下基于Glut 矩阵变换示例程序:中我们在绘制甜圈或者圆柱时使用矩阵对相应的坐标进行变换后自己绘制甜圈或者圆柱.我们也可以使用glLoadMatrixf.glLoadMatrixd载入变 ...

随机推荐

  1. HDFS 处理命令记录

    hdfs dfs -ls hdfs dfs -mkdir hdfs dfs -put hdfs dfs -get hdfs dfs -cat hadoop 执行jar  输出的目录 必须要不存在的 y ...

  2. ASP.net获取当前url各种属性(文件名、参数、域名等)的方法

    假设当前页完整地址是:http://www.test.com/aaa/bbb.aspx?id=5&name=kelli "http://"是协议名 "www.te ...

  3. Reducing the Dimensionality of Data with Neural Networks:神经网络用于降维

    原文链接:http://www.ncbi.nlm.nih.gov/pubmed/16873662/ G. E. Hinton* and R. R. Salakhutdinov .   Science. ...

  4. 【技术累积】【点】【Java】【12】几种常见编码(持续更新)

    问题描述 有这么一段代码: String question = new String(record.getQuestion().getBytes("iso-8859-1"), &q ...

  5. 【sqli-labs】 less16 POST - Blind- Boolian/Time Based - Double quotes (基于bool型/时间延迟的双引号POST型盲注)

    ' or 1=1# -->失败 1" or 1=1# -->失败 1') or 1=1# -->失败 1") or 1=1# -->成功 判断为双引号变形注 ...

  6. class path resource [processes/] cannot be resolved to URL because it does not exist

    springboot整合activiti时报以下错误,原因是项目启动时检查流程文件 nested exception is java.io.FileNotFoundException: class p ...

  7. 【转载】intellij idea如何将web项目打成war包

    1.点击[File]->[Project Structure]菜单(或使用Shift+Ctrl+Alt+S快捷键),打开[Project Structure]窗口.如下图: 2.在[Projec ...

  8. PAT_A1134#Vertex Cover

    Source: PAT A1134 Vertex Cover (25 分) Description: A vertex cover of a graph is a set of vertices su ...

  9. eas之数据融合

    1.如何进行自由融合自由融合无须指定区域,KDTable将根据指定的融合模式,融合相邻且值相等的单元.// 自由行融合table.getMergeManager().setMergeMode(KDTM ...

  10. 【JavaScript】不使用正则表达式和字符串的方式来解析浏览器的URl地址信息

    1.比如我们要获取的网站URl地址是:https://music.163.com/#/playlist?id=2384581760 一般我们能够想到的方式是直接使用正则表达式获取使用字符串直接解析的方 ...