当前位置:网站首页>Trigonometric formula of 3D mathematics
Trigonometric formula of 3D mathematics
2022-07-21 19:58:00 【Just be interesting】
Triangle has two expressions , One is the angle that humans like Degree, One is the curve that mathematics likes Redian.
The conversion between them is
r e d = d e g ∗ ( π / 180 ) = d e g ∗ 0.01745329 d e g = r e d ∗ ( 180 / π ) = r e d ∗ 57.29578 red = deg * (\pi / 180) = deg * 0.01745329\\ deg = red * (180 / \pi) = red * 57.29578\\ red=deg∗(π/180)=deg∗0.01745329deg=red∗(180/π)=red∗57.29578
We don't have to write , The general mathematical library contains the mutual conversion of angles and radians
Mathf.Red2Deg
: 0.01745329
Mathf.Deg2Red
:57.29578
sine sin
and cosine cos
, There are other forms of trigonometric functions
sec θ = 1 cos θ csc θ = 1 sin θ tan θ = sin θ cos θ cot θ = 1 tan θ = cos θ sin θ \sec\theta = \frac{1}{\cos\theta}\qquad \csc\theta = \frac{1}{\sin\theta}\\ \tan\theta = \frac{\sin\theta}{\cos\theta}\qquad \cot\theta = \frac{1}{\tan\theta} = \frac{\cos\theta}{\sin\theta} secθ=cosθ1cscθ=sinθ1tanθ=cosθsinθcotθ=tanθ1=sinθcosθ
Trigonometric identity
sin 2 θ + cos 2 θ = 1 \sin^2\theta + \cos^2\theta = 1 sin2θ+cos2θ=1
General math libraries also provide inverse trigonometric functions , Such as
Asin
,Acos
,Atan
, They can convert it into angles
Trigonometric functions are represented in the unit circle
x = cos θ y = sin θ sin θ 2 + cos θ 2 = 1 x = \cos\theta\\ y = \sin\theta\\ \sin\theta^2+\cos\theta^2 = 1 x=cosθy=sinθsinθ2+cosθ2=1
Other formulas in triangles , Such as sine theorem , Cosine theorem
Sine theorem
sin A a = sin B b = sin C c \frac{\sin A}{a} = \frac{\sin B}{b} = \frac{\sin C}{c} asinA=bsinB=csinC
Cosine theorem
a 2 = b 2 + c 2 − 2 b c cos A b 2 = a 2 + c 2 − 2 a c cos B c 2 = a 2 + b 2 − 2 a b cos C a^2 = b^2 + c^2 - 2bc\cos A\\ b^2 = a^2 + c^2 - 2ac\cos B\\ c^2 = a^2 + b^2 - 2ab\cos C\\ a2=b2+c2−2bccosAb2=a2+c2−2accosBc2=a2+b2−2abcosC
Here is a demonstration of the random rotation of an object , Identify an object that rotates around , Then generate multiple objects to rotate around it .
Center of rotation
public class TriangleText : MonoBehaviour
{
[SerializeField] private int _count = 5;
[SerializeField] private float _radius = 2f;
[SerializeField] private GameObject _prefab;
void Start()
{
// Obtain radians
float red = 2 * Mathf.PI / _count;
for (int i = 0; i < _count; i++)
{
// Get the location
Vector3 position = new Vector3(
Mathf.Cos(red * i) * _radius, transform.position.y, Mathf.Sin(red * i) * _radius);
// Obtain direction
Quaternion quaternion = Quaternion.FromToRotation(Vector3.up, (transform.position - position).normalized);
// establish
Instantiate(_prefab, position + transform.position, quaternion);
}
}
}
A central point
Rotating objects
[SerializeField] private float _rotationSpeed = 30f;
[SerializeField] private Transform _point;
private float _distance;
private float _currentRed;
private Quaternion _rondomRoation;
private void Start()
{
_rondomRoation = Quaternion.AngleAxis(Random.Range(0f, 180f), Random.onUnitSphere);
_rondomRoation = _rondomRoation.normalized;
Debug.Log(_rondomRoation);
_distance = (_point.position - transform.position).magnitude;
_currentRed = Vector3.Angle(Vector3.right, transform.position) * Mathf.Deg2Rad;
if (Vector3.Cross(Vector3.right, transform.position).y < 0)
_currentRed += Mathf.PI;
StartCoroutine(Rotation());
}
private IEnumerator Rotation()
{
while (true)
{
_currentRed = (_currentRed + _rotationSpeed * Mathf.Deg2Rad * Time.deltaTime) % 360f;
float x1 = Mathf.Cos(_currentRed) * _distance;
float y1 = Mathf.Sin(_currentRed) * _distance;
Vector3 position = new Vector3(x1, 0, y1);
position = _rondomRoation * position + _point.position;
Quaternion quaternion =
Quaternion.FromToRotation(Vector3.up, (_point.position - transform.position).normalized);
transform.SetPositionAndRotation(position, quaternion);
yield return null;
}
// ReSharper disable once IteratorNeverReturns
}
object
design sketch
20220720_155057
边栏推荐
- 项目debug|no String-argument constructor/factory method to deserialize from String val
- UML模型和类的六大关系
- How to choose sentinel vs. hystrix current limiting?
- Jenkins插件开发——提供对外访问接口
- input: dynamic input is missing dimensions in profile
- 逐步理解深度信念网络
- QT笔记——QMetaEnum类
- [practice C] find out the single dog
- ctfshow MengXIn misc1
- (4) Transactions
猜你喜欢
实时跟踪用户管理操作
ctfshow MengXIn misc1
Common tools and test methods for interface testing
项目管理成熟度模型及项目量化管理
如何确定你访问的网站的真实性——证书体系
Project Management Maturity Model and project quantitative management
Metauniverse iwemeta: the new cover of time magazine, metauniverse will change everything
(3) Jdbctemplate
(4) Transactions
Iwemeta: Shi Yuzhu's golden sauce wine: OEM factories have been shut down. Who is producing it?
随机推荐
通讯录实现
使用Clip Converter网站下载Yotube视频
QT笔记——QMetaEnum类
如何确定你访问的网站的真实性——证书体系
Project debug|no string argument constructor / factory method to deserialize from string val
The command of gun compiler is g++:$g++ -o prog1 prog1 cc
NXP i.MX 8m Mini development board specifications, quad core arm cortex-a53 + arm cortex-m4
JSP page
STM32——定位模块ATGM336H,数据解析,提取经纬度
论文阅读 (61):Multi-Instance Attention Network for Few-Shot Learning
iwemeta:史玉柱的黄金酱酒:贴牌的代工厂都被关停了,谁在生产?
Read yaml configuration file based on Hydra Library (support command line parameters)
为什么要写单元测试?如何写单元测试?
【To .NET】. Net core web API development process knowledge points sorting [getting started]
接口测试常用工具及测试方法
MySQL (2)
QT notes - qmetaenum class
元宇宙iwemeta:《时代》杂志新封面,元宇宙将改变一切
Bluetooth intelligent nutrition electronic scale solution
NR modulation 4-AM