open3d-点云函数:变换:旋转,缩放、平移,齐次变换(R,T)等

1.代码

代码1:显示文字

python 复制代码
# encoding: utf-8
# module open3d.cpu.pybind.visualization.gui
# from C:\Users\Lenovo\miniconda3\envs\yolov8\lib\site-packages\open3d\cpu\pybind.cp38-win_amd64.pyd
# by generator 1.147
# no doc

# imports
import pybind11_builtins as __pybind11_builtins


class Label3D(__pybind11_builtins.pybind11_object):
    """ Displays text in a 3D scene """
    def __init__(self, arg0, arg1, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ 
        """
        __init__(self: open3d.cpu.pybind.visualization.gui.Label3D, arg0: str, arg1: numpy.ndarray[numpy.float32[3, 1]]) -> None
        
        Create a 3D Label with given text and position
        """
        pass

    color = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
    """The color of the text (gui.Color)"""

    position = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
    """The position of the text in 3D coordinates"""

    scale = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
    """The scale of the 3D label. When set to 1.0 (the default) text will be rendered at its native font size. Larger and smaller values of scale will enlarge or shrink the rendered text. Note: large values of scale may result in blurry text as the underlying font is not resized."""

    text = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
    """The text to display with this label."""

解释

类名

open3d.cpu.pybind.visualization.gui.Label3D

作用:在 3D 场景中显示一段文字(3D 标签)。

python 复制代码
Label3D(text: str, position: np.ndarray[np.float32[3, 1]])
  • text:要显示的文字内容。

  • position:一个形状为 (3, 1) 的 float32 numpy 数组,表示文字在 3D 世界坐标系中的位置 [x, y, z]。

可读写属性

  • text(str):标签文字。

  • position(numpy.ndarray):3D 坐标;直接赋一个新的 (3,) 或 (3,1) 数组即可移动标签。

  • color(gui.Color):文字颜色,例如 gui.Color(r, g, b)。

  • scale(float):文字整体缩放倍数。

    1.0 表示原始字号;>1.0 放大,<1.0 缩小。过大时文字可能变糊,因为底层字体纹理不会重生成。

Label3D 就是在 3D 窗口里放一个可随意定位、改色、缩放的文字标签。

代码2:旋转rotate

python 复制代码
    def rotate(self, R, center): # real signature unknown; restored from __doc__
        """
        rotate(self, R, center)
        Rotate points and lines. Custom attributes (e.g. point normals) are not rotated.
        
        Args:
            R (open3d.core.Tensor): Rotation [Tensor of shape (3,3)].
            center (open3d.core.Tensor): Center [Tensor of shape (3,)] about which the LineSet is to be rotated. Should be on the same device as the LineSet.
        
        Returns:
            open3d.t.geometry.LineSet
        """
        pass

解释

作用

线集(LineSet) 的所有顶点和线段,绕指定中心 center旋转,返回旋转后的新 LineSet。

参数

  • R (open3d.core.Tensor):旋转矩阵,形状 (3, 3)

  • center (open3d.core.Tensor):旋转中心,形状 (3,);必须与 LineSet 在同一设备(CPU 或 CUDA)。

返回值

一个新的 open3d.t.geometry.LineSet(原对象不变)。

注意

只旋转"点"和"线",不会自动旋转自定义属性(如顶点法线、颜色等)。

代码3 缩放scale

python 复制代码
    def scale(self, scale, center): # real signature unknown; restored from __doc__
        """
        scale(self, scale, center)
        Scale points and lines. Custom attributes are not scaled.
        
        Args:
            scale (float): Scale magnitude.
            center (open3d.core.Tensor): Center [Tensor of shape (3,)] about which the LineSet is to be scaled. Should be on the same device as the LineSet.
        
        Returns:
            open3d.t.geometry.LineSet
        """
        pass

解释

作用

把当前线集(LineSet)的所有顶点与线段以指定中心为基准做均匀缩放,返回一个新的线集对象;原对象保持不变。

参数

  • scale (float):缩放倍数。

    • scale > 1 放大,

    • 0 < scale < 1 缩小,

    • scale < 0 会镜像翻转。

  • center (open3d.core.Tensor):缩放的中心点,形状 (3,);必须与线集位于同一设备(CPU/GPU)。

返回值

新的 open3d.t.geometry.LineSet

注意

仅对"点"和"线"几何坐标生效,不会自动缩放自定义属性(如颜色、法线、宽度等)。

代码4:平移translate

python 复制代码
    def translate(self, translation, relative=True): # real signature unknown; restored from __doc__
        """
        translate(self, translation, relative=True)
        Translates points and lines of the LineSet.
        
        Args:
            translation (open3d.core.Tensor): Translation tensor of dimension (3,). Should be on the same device as the LineSet
            relative (bool, optional, default=True): If true (default) translates relative to center of LineSet.
        
        Returns:
            open3d.t.geometry.LineSet
        """
        pass

解释

功能

把线集中所有顶点(以及线段)整体平移 指定向量,返回一个新的 LineSet;原对象不变。

参数

  • translation (open3d.core.Tensor): 平移向量,形状 (3,),元素顺序 [dx, dy, dz]

    必须与线集在同一设备(CPU 或 CUDA)。

  • relative (bool, 默认 True):

    • True → 把线集自身中心 作为原点,再施加 translation

    • False → 直接把 translation 加到每个顶点上(世界坐标系)。

返回值

新的 open3d.t.geometry.LineSet

代码5:齐次变换矩阵(R,T)-旋转+平移

python 复制代码
    def transform(self, transformation): # real signature unknown; restored from __doc__
        """
        transform(self, transformation)
        Transforms the points and lines. Custom attributes (e.g. point normals) are not
        transformed. Extracts R, t from the transformation as:
        
        .. math::
            T_{(4,4)} = \begin{bmatrix} R_{(3,3)} & t_{(3,1)} \\
                                    O_{(1,3)} & s_{(1,1)} \end{bmatrix}
        
        It assumes :math:`s = 1` (no scaling) and :math:`O = [0,0,0]` and applies the
        transformation as :math:`P = R(P) + t`
        
        Args:
            transformation (open3d.core.Tensor): Transformation [Tensor of shape (4,4)].  Should be on the same device as the LineSet
        
        Returns:
            open3d.t.geometry.LineSet
        """
        pass

解释

作用

4×4 齐次变换矩阵 一次性对线集做 旋转 + 平移 ,返回新的 LineSet

(矩阵里的缩放因子 s 被强制设为 1,不做缩放;原点 O 必须为 [0,0,0]。)

数学表达

若矩阵

T = [ R t ]

0 1

则对每个点 P:

P′ = R·P + t

参数

  • transformation (open3d.core.Tensor):形状 (4,4) 的齐次矩阵,需与线集在同一设备 (CPU/GPU)。

返回值

新的 open3d.t.geometry.LineSet(原对象不变)。

注意:自定义属性(颜色、法线等)不会被自动变换。

2.代码-关于点云的变换

代码:旋转 rotate

python 复制代码
    def rotate(self, R, center): # real signature unknown; restored from __doc__
        """
        rotate(self: open3d.cpu.pybind.t.geometry.PointCloud, R: open3d.cpu.pybind.core.Tensor, center: open3d.cpu.pybind.core.Tensor) -> open3d.cpu.pybind.t.geometry.PointCloud
        
        Rotate points and normals (if exist).
        """
        pass

代码:缩放 sacle

python 复制代码
    def scale(self, scale, center): # real signature unknown; restored from __doc__
        """
        scale(self: open3d.cpu.pybind.t.geometry.PointCloud, scale: float, center: open3d.cpu.pybind.core.Tensor) -> open3d.cpu.pybind.t.geometry.PointCloud
        
        Scale points.
        """
        pass

代码:平移 translate

python 复制代码
    def translate(self, translation, relative=True): # real signature unknown; restored from __doc__
        """
        translate(self: open3d.cpu.pybind.t.geometry.PointCloud, translation: open3d.cpu.pybind.core.Tensor, relative: bool = True) -> open3d.cpu.pybind.t.geometry.PointCloud
        
        Translates points.
        """
        pass

代码:齐次变换 transform

python 复制代码
    def transform(self, transformation): # real signature unknown; restored from __doc__
        """
        transform(self: open3d.cpu.pybind.t.geometry.PointCloud, transformation: open3d.cpu.pybind.core.Tensor) -> open3d.cpu.pybind.t.geometry.PointCloud
        
        Transforms the points and normals (if exist).
        """
        pass
相关推荐
熬了夜的程序员16 小时前
【LeetCode】89. 格雷编码
算法·leetcode·链表·职场和发展·矩阵
vvvdg1 天前
求下列线性变换的矩阵
线性代数·矩阵·1024程序员节
数智顾问1 天前
矩阵的奇异值分解(SVD)在三维图形学中的进阶应用
矩阵
大千AI助手2 天前
Frobenius范数:矩阵分析的万能度量尺
人工智能·神经网络·线性代数·矩阵·矩阵分解·l2范数·frobenius范数
会编程是什么感觉...2 天前
数学 - 基础线性代数
线性代数
吃着火锅x唱着歌3 天前
LeetCode 74.搜索二维矩阵
算法·leetcode·矩阵
dingzd953 天前
全平台内容排期与矩阵玩法
人工智能·线性代数·矩阵·web3·facebook·tiktok·instagram
陈苏同学3 天前
笔记1.4:机器人学的语言——三维空间位姿描述 (旋转矩阵 - 齐次变换矩阵 - 欧拉角 - 四元数高效表示旋转)
笔记·线性代数·算法·机器人
前端世界3 天前
从零实现一个可加减的Matrix矩阵类:支持索引、相等判断与实际场景应用
线性代数·矩阵
qq_ddddd4 天前
对于随机变量x1, …, xn,其和的范数平方的期望不超过n倍各随机变量范数平方的期望之和
人工智能·神经网络·线性代数·机器学习·概率论·1024程序员节