Transform.inversetransformpoint Reverse Transform Point

Source: Internet
Author: User

JavaScript? Public Function Inversetransformpoint(position: Vector3): Vector3;
C#? public Vector3 inversetransformpoint(Vector3 position);

Description Description

Transforms position from World space to local space. The opposite of Transform.transformpoint.

Transforms the position from world coordinates to local coordinates. The opposite of Transform.transformpoint.

Note that the returned position are affected by scale. Use the transform.inversetransformdirection if you is dealing with directions.

Note that the return position is affected by scaling. If you are dealing with directions use transform.inversetransformdirection.

Javascript:

Calculate the transform ' s position relative to the camera.var cam = Camera.  Main. transform; var camerarelative = Cam.  Inversetransformpoint(transform.  Position); if (camerarelative.  Z > 0) print ("The object is in front of the camera"); Else Print ("The object is behind the camera");        

C#:

UsingUnityengine;UsingSystem.Collections;PublicClass ExampleClass: Monobehaviour{Public Transform Cam= Camera.Main.Transform;public Vector3 camerarelative = cam. Inversetransformpoint (Transform. Positionvoid example ({if Span class= "Br0" > (Camerarelative. Z > 0) print ( "the Object is in front of the camera ") else print ( "The object is behind the camera"  ) }}            /span>                

JavaScript? Public Function inversetransformpoint(x: float, y: float, z: float): Vector3;
C#? public Vector3 inversetransformpoint(float x, float y, float z);

Description Description

Transforms the position x, Y, z from World space to local space. The opposite of Transform.transformpoint.

Transform position x, Y, z from world coordinates to local coordinates. The opposite of Transform.transformpoint.

Note that the returned position are affected by scale. Use the transform.inversetransformdirection if you is dealing with directions.

Note that the return position is affected by scaling. If you are dealing with directions use transform.inversetransformdirection.

Javascript:

//Calculate the world origin relative to this Transform. relativepoint = transform. Inversetransformpoint (00 0 if  (Relativepoint. Z > 0) print  ( "the World origin was in front of the This object ") else print  ( "the world origin was behind of this object"              

C#:

UsingUnityengine;UsingSystem.Collections;PublicClass ExampleClass: Monobehaviour{void example ({relativepoint = transform. Inversetransformpoint (0, 0, 0 if  (Relativepoint. Z > 0) print ( "the World origin was in front of the This object ") else print ( "the world origin was behind of this object" ; }}            /span>                

? Transform

Transform. Inversetransformpoint and transform. Transformpoint, what's going on?

One is to transform its own coordinates into world coordinates, one is to transform the world coordinates to its own coordinates.

For example, there is a 3,3,3 point in the coordinates of object A. You want to know that this point should be used in the world coordinates transformpoint

And there's a point in the world coordinates. You want to know if it's a position in the coordinates of object A, you should use Inversetransformpoint.

In fact, it's a conversion between the position of the object in the editor and the position of the object within the object.

Transform.inversetransformpoint Reverse Transform Point

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.