Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by robinking · Mar 03, 2011 at 10:46 AM · transformpoint

Need equivalent of Transform.TransformPoint() but without using transforms

I want to be able to do the equivalent of this:

var localpos = Vector3(0,0,2);
var tPoint = transform.TransformPoint( localpos );

But without using a transform - so instead:

var pos = transform.position;
// should I use a quaternion instead?
var angle = transform.eulerAngles;
var localpos = Vector3(0,0,2);
var tPoint = // ???

(I realise in this example, it's a bit redundant - my real code would require an empty gameObject added which I don't want.)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by Bunny83 · Mar 03, 2011 at 11:18 AM

The best way of doing that is using a Matrix4x4 any other method would result in a lot of calculations on your side. You don't need scaling, right? Why don't you want to use a empty GO, it's the easiest way of doing that and you have visual debugging support integrated ;)

Anyways, use Matrix4x4.TRS to setup your matrix and don't use eulerangles. Eulerangles have a big problem that they can't represent all possible rotations (transitions to achieve the resulting rotation). That's why we have Quaternions. Even the TRS function needs a Quaternion.

If you have created your matrix you can multiply your point with the matrix. The same matrix is already used inside of a Transform. You can get the matrix with transform.localToWorldMatrix.

Some further information on matrices of that type:
http://en.wikipedia.org/wiki/Transformation_matrix


edit
Just came to my mind: I think that should work too:

var rotation : Quaternion; var position : Vector3; var localpos = Vector3(0,0,2);

var tPoint = rotation * localpos + position;

(of course without scaling!)

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image robinking · Mar 03, 2011 at 12:00 PM 0
Share

Perfect! Just what I needed, thanks!

avatar image robinking · Mar 03, 2011 at 03:19 PM 0
Share

Aha! Even easier! Thanks again :)

avatar image dreasgrech · Apr 18, 2015 at 11:04 AM 0
Share

Thanks, works perfectly.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Let a plane follow the camera 1 Answer

air craft crash 1 Answer

TransformPoint - different results in Awake() and Start() 0 Answers

Transform coordinates to local space with quaternion 1 Answer

Isometric Raycast: misplaced origin & not updating position with TransformPoint 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges