方向向量转欧拉角,将2 3D点转换为方向向量再转换为欧拉角

Here's essentially my problem. Also maybe I am not familiar enough with Euler angles and what I'm attempting to do is not possible.

I have 2 points in 3d space.

p1 (1,2,3)

p2 (4,5,6)

In order to get the unit vectors for these two points I'm doing this basically.

var productX = (position.X2 - position.X1);

var productY = (position.Y2 - position.Y1);

var productZ = (position.Z2 - position.Z1);

var normalizedTotal = Math.sqrt(productX * productX + productY * productY + productZ * productZ);

var unitVectorX, unitVectorY, unitVectorZ;

if(normalizedTotal == 0)

{

unitVectorX = productX;

unitVectorY = productY;

unitVectorZ = productZ;

}

else

{

unitVectorX = productX / normalizedTotal;

unitVectorY = productY / normalizedTotal;

unitVectorZ = productZ / normalizedTotal;

}

So now I have a unit vector x y z for these 2 3d points.

I'm attempting now to convert from directional vector to euler angle. Is this possible. What am I missing here as I can't find any good resource on how to do this.

Thanks for the help.

Sometimes a picture helps.

0cc0a1a2a26602df2ac8b6565b64fe71.png

maybe this will give a better example of what i'm trying to solve for.

Given 2 points, I have determined a midpoint, length, and now i'm trying to figure out hte angles to set so that the cylinder is correctly oriented around the x,y,z axis. I think I need to figure out all 3 angles not just 1 and 2 is that correct? I think the euler angles from a directional vector bit through you off.

解决方案

What you want is a transformation from Cartesian coordinates of the vector

v = (v_x, v_y, v_z)

to the spherical coordinates r, ψ and θ where

v = ( r*COS(ψ)*COS(θ), r*SIN(θ), r*SIN(ψ)*COS(θ) )

This is done with the following equations

r = SQRT(v_x^2+v_y^2+v_z^2)

TAN(ψ) = (v_z)/(v_x)

TAN(θ) = (v_y)/(v_x^2+v_z^2)

To get the angles ψ and θ, use the ATAN2(dy,dx) function as in

ψ = ATAN2(v_z, v_x)

θ = ATAN2(v_y, SQRT(v_x^2+v_z^2))

Now that you have the along direction vector

j = ( COS(ψ)*COS(θ), SIN(θ), SIN(ψ)*COS(θ) )

you can get the two perpendicular vectors from

i = ( SIN(ψ), 0, -COS(ψ) )

k = ( COS(ψ)*SIN(θ), -COS(θ), SIN(ψ)*SIN(θ) )

These three vectors make up the columns of the 3×3 rotation matrix

| SIN(ψ) COS(ψ)*COS(θ) COS(ψ)*SIN(θ) |

E =[i j k] = | 0 SIN(θ) -COS(θ) |

| -COS(ψ) SIN(ψ)*COS(θ) SIN(ψ)*SIN(θ) |

In terms of Euler angles the above is equivalent to

E = RY(π/2-ψ)*RX(π/2-θ)

Example

Two points p_1=(3,2,3) and p_2=(5,6,4) define the vector

v = (5,6,4) - (3,2,3) = (2,4,1)

NOTE: I am using the notation of v[i] for the i-th element of the vector, as in v[1]=2 above. This is neither like C, Python which is zero based, nor like VB, FORTRAN or MATLAB which uses parens () for the index.

Using the expressions above you get

r = √(2^2+4^2+1^2) = √21

TAN(ψ) = 1/2

TAN(θ) = 4/√(2^2+1^2) = 4/√5

ψ = ATAN2(1,2) = 0.463647

θ = ATAN2(4,√5) = 1.061057

Now to find the direction vectors

j = ( COS(ψ)*COS(θ), SIN(θ), SIN(ψ)*COS(θ) ) = (0.4364, 0.87287, 0.21822 )

i = ( SIN(ψ), 0, -COS(ψ) ) = (0.44721, 0, -0.89443 )

k = ( COS(ψ)*SIN(θ), -COS(θ), SIN(ψ)*SIN(θ) ) = (0.78072, -0.48795, 0.39036)

Put the direction vectors as columns of the local to world coordinate transformation (rotation)

E[1,1] = i[1] E[1,2] = j[1] E[1,3] = k[1]

E[2,1] = i[2] E[2,2] = j[2] E[2,3] = k[2]

E[3,1] = i[3] E[3,2] = j[3] E[3,3] = k[3]

| 0.447213595499957 0.436435780471984 0.780720058358826 |

| |

E = | 0 0.872871560943969 -0.487950036474266 |

| |

| -0.894427190999915 0.218217890235992 0.390360029179413 |

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
智慧校园整体解决方案是响应国家教育信息化政策,结合教育改革和技术创新的产物。该方案以物联网、大数据、人工智能和移动互联技术为基础,旨在打造一个安全、高效、互动且环保的教育环境。方案强调从数字化校园向智慧校园的变,通过自动数据采集、智能分析和按需服务,实现校园业务的智能化管理。 方案的总体设计原则包括应用至上、分层设计和互联互通,确保系统能够满足不同用户角色的需求,并实现数据和资源的整合与共享。框架设计涵盖了校园安全、管理、教学、环境等多个方面,构建了一个全面的校园应用生态系统。这包括智慧安全系统、校园身份识别、智能排课及选课系统、智慧学习系统、精品录播教室方案等,以支持个性化学习和教学评估。 建设内容突出了智慧安全和智慧管理的重要性。智慧安全管理通过分布式录播系统和紧急预案一键启动功能,增强校园安全预警和事件响应能力。智慧管理系统则利用物联网技术,实现人员和设备的智能管理,提高校园运营效率。 智慧教学部分,方案提供了智慧学习系统和精品录播教室方案,支持专业级学习硬件和智能化网络管理,促进个性化学习和教学资源的高效利用。同时,教学质量评估中心和资源应用平台的建设,旨在提升教学评估的科学性和教育资源的共享性。 智慧环境建设则侧重于基于物联网的设备管理,通过智慧教室管理系统实现教室环境的智能控制和能效管理,打造绿色、节能的校园环境。电子班牌和校园信息发布系统的建设,将作为智慧校园的核心和入口,提供教务、一卡通、图书馆等系统的集成信息。 总体而言,智慧校园整体解决方案通过集成先进技术,不仅提升了校园的信息化水平,而且优化了教学和管理流程,为学生、教师和家长提供了更加便捷、个性化的教育体验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值