简体   繁体   English

求解齐次坐标 (x,y,z,w) 中两个 3D 向量的叉积

[英]Solving the crossproduct of two 3D vectors in homogenuous coordinates (x,y,z,w)

I want to calculate the cross product of x and vector y without numpy or any imports.我想在没有 numpy 或任何导入的情况下计算x和向量y的叉积。

x = Vector(1,2,1,0)  
y = Vector(0,1,2,1)

but my result is always wrong.但我的结果总是错误的。 what am i missing here?我在这里想念什么?

def crossproduct(x, y):
        final = Vector()
        final.v[0] = y.v[1] * v.v[2] - x.v[2] * y.v[1]
        final.v[1] = y.v[2] * v.v[3] - x.v[3] * y.v[2]
        final.v[2] = y.v[3] * v.v[0] - x.v[0] * y.v[3] 
        final.v[3] = y.v[0] * v.v[1] - x.v[1] * y.v[0]
        return final

Solving cross on a Vec4 (homogenuous) is the same as solving it as a Vec3 (Cartesian), since you're in 3 dimensions, no matter how you use the w component.Vec4 (同质)上求解交叉与将其作为Vec3 (笛卡尔)求解相同,因为无论您如何使用w分量,您都处于 3 维中。

Check your cross formula, the one I usually use looks like this:检查您的交叉公式,我通常使用的公式如下所示:

crossX = vector1.Y * vector2.Z - vector2.Y * vector1.Z
crossY = -(vector1.X * vector2.Z - vector2.X * vector1.Z)
crossZ = vector1.X * vector2.Y - vector2.X * vector1.Y
crossW = 0.0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 3d将x,y,z坐标转换为3d numpy数组 - 3d coordinates x,y,z to 3d numpy array 获取 3D 中平面给定 x 和 z 的 y 坐标 - Get y coordinates given x and z for a plane in 3D 如何绘制来自3个不同列表(x,y和z)的3d直方图,其中z是所有重复的x,y坐标的平均值 - How to plot a 3d histogram from 3 different lists (x, y and z), where z is the mean of all repeated x,y coordinates 在Python中实现3D向量:numpy vs x,y,z字段 - Implementing 3D vectors in Python: numpy vs x,y,z fields 如何将n,y,z坐标数组转换为numpy中的3D路径 - How to convert arrays of x,y,z coordinates to 3D path in numpy Python:创建 X、Y 坐标和相应的计算 Z 值的网格以生成 XYZ 的 3D 数组 - Python: Creating a Grid of X,Y coordinates and corresponding calculated Z values to result in a 3D array of XYZ 在给定 x,y,z 坐标时使用 DBSCAN 算法使用 python 对 3D 点进行聚类 - Clustering the 3D points when given the x,y,z coordinates using DBSCAN algorithm using python 给定 x,y,z 坐标的数据,我将如何在 Matplotlib 中制作 3D 表面 plot? - How would I make a 3D surface plot in Matplotlib given this data of x,y,z coordinates? 如何在Python中获取每次单击的3D模型的(x,y,z)坐标? - How to get the (x,y,z) coordinates of a 3D model of every click in Python? JavaScript Plotly.js 如何使用 x、y 和 z 坐标创建 3D 表面 plot? - JavaScript Plotly.js How to create a 3D surface plot using x, y, and z coordinates?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM