物体围绕某个点旋转一定角度

转自:https://dawnarc.com/2016/06/ue4%E7%BA%BF%E6%80%A7%E4%BB%A3%E6%95%B0%E7%89%A9%E4%BD%93%E5%9B%B4%E7%BB%95%E6%9F%90%E4%B8%AA%E7%82%B9%E6%97%8B%E8%BD%AC%E4%B8%80%E5%AE%9A%E8%A7%92%E5%BA%A6/

2D上的点围绕某另一个点旋转: If you rotate point (px, py) around point (ox, oy) by angle theta you’ll get:

p‘x = cos(theta) * (px-ox) - sin(theta) * (py-oy) + ox
p‘y = sin(theta) * (px-ox) + cos(theta) * (py-oy) + oy

this is an easy way to rotate a point in 2D.

=======================================http://stackoverflow.com/questions/13275719/rotate-a-3d-point-around-another-one Try to use vector math. decide in which order you rotate, first along x, then along y perhaps.

If you rotate along z, [z’ = z]

x‘ = x*cos a - y*sin a;
y‘ = x*sin a + y*cos a;
The same repeated for y-axis: [y‘‘ = y‘]

x‘‘ = x‘*cos b - z‘ * sin b;
z‘‘ = z‘*sin b + x‘ * cos b;
Again rotating along x-axis: [x‘‘‘ = x‘‘]

y‘‘‘ = y‘‘ * cos c - z‘‘ * sin c
z‘‘‘ = z‘‘ * sin c + y‘‘ * cos c

And finally the question of rotating around some specific “point”:

First subtract the point from the coordinates, then apply the rotations and finally add the point back to the result.

The problem, as far as I see, is a close relative to “gimbal lock”. The angle w_ny can’t be measured relative to the fixed xyz -coordinate system, but to the coordinate system that is rotated by applying the angle w_nx.

As kakTuZ observed, your code converts point to spherical coordinates. There’s nothing inherently wrong with that – with longitude and latitude one can reach all the places in Earth. And if one doesn’t care about tilting the Earth equatorial plane relative to it’s trajectory around the Sun, it’s ok with me.

The result of not rotating the next reference axis along the first w_ny is that two points that are 1 km a part of each other at equator, move closer each other at the poles and at latitude of 90 degrees, they touch. Even though the apparent purpose is to keep them 1 km apart where ever they are rotated.

================================== UE4中的实现方式

FVector A;
FVector B;
FRotator C;

A点绕B点旋转C之后的坐标:

B+C.RotateVector(A-B)

其他参考: Quaternions and spatial rotationhttps://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation

Rotation matrix https://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations

原文地址:https://www.cnblogs.com/sevenyuan/p/9373931.html

时间: 2024-08-29 05:46:34

物体围绕某个点旋转一定角度的相关文章

unity实现一个物体绕着某点旋转

transform.RotateAround(o.transform.position,Vector3.up,20*Time.deltaTime);transform.Rotate(Vector3.up, 20*Time.deltaTime, Space.World); RotateAround():让物体围绕招某点旋转,参数分别为,旋转的点坐标,旋转的方向,旋转的速度. Rotate():让物体自传,参数分别为:旋转的方向,旋转的速度,旋转的坐标系(世界坐标系和自身坐标系). 原文地址:htt

css控制div元素旋转指定角度代码实例

css控制div元素旋转指定角度代码实例:本章节介绍一下如何利用css3实现控制元素旋转指定角度的效果.在这里咱们就不考虑低版本的浏览器,因为随着时间的推移,低版本的浏览器会被逐渐淘汰,就算是当前,低版本浏览器的用户的占比也是很少了,下面直接看代码实例: <!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" conten

一个坐标点围绕任意中心点旋转--C#实现

假设对图片上任意点(x,y),绕一个坐标点(rx0,ry0)逆时针旋转RotaryAngle角度后的新的坐标设为(x', y'),有公式: x'= (x - rx0)*cos(RotaryAngle) + (y - ry0)*sin(RotaryAngle) + rx0 ;    y'=-(x - rx0)*sin(RotaryAngle) + (y - ry0)*cos(RotaryAngle) + ry0 ; /// <summary> /// 对一个坐标点按照一个中心进行旋转 /// &

Android -- ImageView(控制图片的大小以及旋转的角度)

1.  2.   实现代码 package com.example.myimageview3; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.Matrix; import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; import android.util.DisplayMetrics

JQuery插件让图片旋转任意角度且代码极其简单

引入下方的jquery.rotate.js文件,然后通过$("选择器").rotate(角度);可以旋转任意角度, 例如$("#rotate-image").rotate(45);把这句放在$(document).ready(function(){ });中 就是将id为rotate-image的图片旋转45度. 不过,貌似在Chrome中总是不显示. 唉,找了两个小时,才发现Chrome太坑爹了,没法获取图片的长宽. 解决办法是,把$("#rotate-

C# 点绕某点旋转某角度

/// <summary> /// 以中心点旋转Angle角度 /// </summary> /// <param name="center">中心点</param> /// <param name="p1">待旋转的点</param> /// <param name="angle">旋转角度(弧度)</param> private void Poin

unity3d一个物体围绕另一个物体旋转

可以使用RotateAround,代码如下: transform.RotateAround (Sun.transform.position, Vector3.down, 5); 其中第一个参数是要围绕哪一个对象来旋转,Sun.transform.position表示的是Sun的中心点. 第二个参数是指要围绕哪一个轴来旋转,Vector3.down表示围绕y轴负向旋转(也可以理解为逆时针),如果是Vector.up表示顺时针. 第三个参数之每一帧移动的角度,这里为5度.

实现物体绕不同轴旋转,并可以外部调用的函数

第一个文件,声明枚举类型,分别为均匀变化和加速变化 1 2 3 4 5 6 7 8 using UnityEngine; using System.Collections; public enum CTRotationType {     Uniform,     AccelerateUniformly } 第二个文件:主函数,实现围绕轴变化的两个函数,分别为均匀变化和加速变化   1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

旋转任意角度 如何让div旋转一定的角度 (转)

<html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>DIV旋转属性的演示</title> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8&q