Unity3d for VR Learning (6): restudying -3d Math again

Source: Internet
Author: User
Tags scalar

A year ago, the system learned 3D math and recorded a blog, "C # Programmer's Consolidation of Unity 3D notes (10): Unity3d's displacement, rotational 3D mathematical model." A year later, review it again.

Coordinate system: Unity3d use left-handed Cartesian coordinate system ( Descartes coordinate system)
    • World coordinate system : In a game scene, the only.
    • object coordinate system \ Local coordinate system (local\object space): Each object has its own independent coordinate system. In the object coordinate system of the table, the armrest is relative to the table leg position. Sometimes, there is no need to leak too much detail.
    • Camera coordinate system : A special object coordinate system for defining objects within the camera's field of view, i.e. those objects are drawn by the camera.
    • Inertial coordinate system (intertial): a "temporary" coordinate system, in order to facilitate the conversion from the world coordinate system to the object coordinate system, the new coordinate system is introduced. The origin and object coordinate system coincide, and the axes are parallel to the world coordinate system.

Unity3d provides a useful coordinate system conversion tool:

1 recttransformutility

Vector2 Worldtoscreenpoint (Camera cam, Vector3 worldpoint)

Ray Screenpointtoray (Camera cam, Vector2 screenpos)

2 "Unity3d Project Practical Notes (1): Prefab plug-in mode"

The following code can make: A.prefab is loaded under a sub-node, to make a display B point position, one way is to hook A to B; another way is to use the 2 methods provided by transform, convert local coordinates to world coordinates, to achieve dynamic positioning.

Vector3 pos = a.transform.transformpoint (a.localpostion);

B.localpostion = B.transform.inversetransformpoint (POS);

Vector: With size and direction, no position

At any point, it can be expressed as vectors from the origin, and this is where points and vectors are very easy for beginners to confuse. At the same time, vectors can be used anywhere in the coordinate system because the vectors are independent of position.

    • Vector multiplication, adding the coefficient of force adjustment by multiplying scalar and vector
    • Vector normalization with a vector size of 1. Also known as "normal"
    • A negative vector, equal to the original vector, and a vector in the opposite direction
    • Vector addition, vector A and vector b wrap vector, from the end of a to the head of B.
    • Vector subtraction, identical vector addition.
    • Vector point Multiplication (inner product), the result is scalar, describes the "similarity" degree of two vectors, the larger the result of the point multiplication, the closer the vector.

A.B >0: [0, 90), same direction

a.b = 0:90° Vector orthogonal

A.b<0: (90,180] in the opposite direction

    • Vector Fork Multiplication (cross product), which results in two vectors perpendicular to the original.
Matrices (matrix), mainly 2*2, 3*3, 4*4 phalanx

DirectX uses a row vector, and Ope6ngl uses a column vector. The row of a square can be interpreted as a base vector

Linear transformations hold straight and parallel lines, the origin is not moved, and the transformation containing the translation is called an affine transformation.

The difference between a transformed object and a transformation coordinate system: Transforming an object, such as a rotation of 20 °, means that all points on an object need to be recalculated and moved to a new position. When the coordinate system is rotated, the point on the object does not actually move, but it is only described in another coordinate system, and sometimes a transformation coordinate system can be used to save the underlying computational capacity. (such as collision detection, the object to be involved in the same coordinate system)

Linear transformations do not result in panning (the origin position does not change), and the radiation transformation is then translated on the basis of online.

The determinant of the matrix, and the result is a scalar.

The orthogonal matrix, if the matrix is orthogonal, is multiplied by its transpose matrix, and the result is the unit matrix. At the same time, it is known that the transpose matrix of the orthogonal matrix is the inverse matrix.

Orthogonal projections (dimensionality reduction operations), also known as parallel projections. 3D is projected onto the 2D screen, which is called the projection plane.

Perspective projection, the projection line is no longer parallel but intersects at a point – the projection center. Similar to "keyhole imaging", the projection is inverted.

Euler angle, using three angles to save the azimuth: Heading,y axis, ( -180,180); pitch, x-axis, (-90, 90); Bank, Z axis, (-180,180).

Four Yuan (quation), with 4 numbers to express the azimuth, to avoid the Euler angle "universal lock", slerp spherical difference problem.

Reference books:

    • Fundamentals of 3D Mathematics: graphics and game development
    • "Mathematics for 3D Game programming and Computer Graphics"

Like, Storm Mirror 4 + millet note top with 2K screen, a milestone, can play VR for 20 minutes or more :

The resolution is good and the gyroscope is good.

In contrast, the thousand-dollar machine charm Blue Note 2 is a slag: away from the thousand-yuan machine, if you play VR words.

VR in the future, may be a small regret: 5 years ago on a number of business trip to Harbin, just have snow and ice Big World, the heart is still pretty want to see, but because of fear of cold ( -35° long time outdoor activities), it was unable to travel. If you can see through the VR remote, then the better, hehe.


Reprint please indicate transfer from "Unity3d for VR Learning" (6): Restudying -3d Mathematics again

Unity3d for VR Learning (6): restudying -3d Math again

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.