Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by canis · Jan 28, 2016 at 04:48 PM · transformquaternionmathvector

TransformPoint/Direction/Vector Equation?

Actually I'm working on my expansion script, however I lack of math knowledge, cannot do it myself even google I didn't know the real keyword for the answer.. I did try it before. so I put it here, hope someone can guide me.

What I need is the equation in code : - TransformPoint - TransformDirection - TransformVector - InverseTransformPoint - InverseTransformDirection - InverseTransformVector

I wish to calculate the above result without using any GameObject, which mean no transform at all. not good at math, so I only able to find out the "TransformPoint", and I put it here,

 public static Vector3 TransformPoint(this Vector3 position, Quaternion rotate, Vector3 offset)
 {
     return position +
         ((rotate * Vector3.right).normalized * offset.x) +
         ((rotate * Vector3.up).normalized * offset.y) +
         ((rotate * Vector3.forward).normalized * offset.z);
 }

sorry for my bad English. hope you guys understand :)

Comment
Add comment · Show 2
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 canis · Jan 28, 2016 at 05:42 PM 0
Share

just find out I can do it like that for TransformPoint & InverseTransformPoint

 public static Vector3 TransformPoint(this Vector3 position, Quaternion rotate, Vector3 offset)
 {
     return position + rotate * offset;
 }
 public static Vector3 InverseTransformPoint(this Vector3 position, Quaternion rotate, Vector3 targetPosition)
 {
     return rotate.Inverse() * (targetPosition - position);
 }

Now need to do the direction. hope I can solve it right.

avatar image canis · Jan 29, 2016 at 04:10 PM 0
Share

I just realize I didn't do it right, forgot to calculate the scale here is the upgrade version.

 public static Vector3 TransformPoint(this Vector3 position, Quaternion localRotate, Vector3 localScale, Vector3 offset)
 {
             return position + localRotate * Vector3.Scale(offset, localScale); // ok
 }
 public static Vector3 TransformPoint(this $$anonymous$$atrix4x4 matrix, Vector3 offset)
 {
             return TransformPoint(matrix.GetPosition(), matrix.GetRotation(), matrix.GetScale(), offset);
 }


0 Replies

· Add your reply
  • Sort: 

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

36 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Help with rotating camera around object based on mouse input 0 Answers

[Solved] Quaternion from IMU sensor to GameObject Orientation problem 3 Answers

limit Quaternion.Euler rotation 2 Answers

Character rotation on ledge hanging 0 Answers

3 Axis Camera Rotation 0 Answers


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