5 实现矩阵变换在图形学中的应用&实现单位矩阵以及逆矩阵

本文介绍了如何在Python环境下,利用numpy库实现矩阵的变换,包括创建单位矩阵的功能以及矩阵的逆矩阵计算。通过引入matplotlib进行可视化展示,加深对线性代数中矩阵变换的理解。
摘要由CSDN通过智能技术生成

创建新的py文件实现矩阵的变换 ==> main_matrix_transformation.py
引入 python中的绘制包 matplotlib ==> import matplotlib.pyplot as plt

import matplotlib.pyplot as plt
from playLA.Matrix import Matrix
from playLA.Vector import Vector
import math

if __name__ == '__main__':
    points = [[0,0],[0,5],[3,5],[3,4],[1,4],
              [1,3],[2,3],[2,2],[1,2],[1,0]]
    x = [point[0] for point in points]
    y = [point[1] for point in points]

    plt.figure(figsize=(5,5)) # 单位为英尺,设置坐标系
    plt.xlim(-10,10) # 设置x轴范围
    plt.ylim(-10,10)

    plt.plot(x,y)
    # plt.show()  # plt函数会根据点坐标进行坐标系的自适应

    P = Matrix(points)

    # T = Matrix([[2,0],[0,1.5]])
    # T = Matrix([[1,0],[0,-1]])
    # T = Matrix([[-1, 0], [0, 1]])
    # T = Matrix([[-1, 0], [0, -1]])
    # T = Matrix([[1, 0.5], [0, 1]])
    # T = Matrix([[1, 0], [0.5, 1]])
    theta = math.pi/3
    T = Matrix([[math.cos(theta),math.sin(t
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值