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 sysameca · Jun 06, 2014 at 01:27 PM · vectornormalperpendicular

Getting perpendicular direction vector from surface normal

Hello guys. My problem which i can't solve is this: I want to find out the perpendicular direction of a normal (the red arrow) from the surface normal (green line) which must always point at the direction of the ray (light purple color).Just to clarify: i know how to find the perpendicular of the normal, but i don't know how to get the correct perpendicular in order to achieve the result from the image.alt text

direction.jpg (51.1 kB)
Comment
Add comment · Show 1
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 AlucardJay · Jun 06, 2014 at 03:01 PM 0
Share

This will not be easy, check the answer here

2 Replies

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

Answer by DMGregory · Jun 06, 2014 at 03:17 PM

Try:

 Vector3 surfaceParallel = direction - normal * Vector3.Dot(direction, normal);

This subtracts any part of direction that's parallel to normal, leaving only the perpendicular component. Note that if direction and normal are completely parallel, this will give you a zero vector. In other cases, you can normalize it to get a unit vector in the desired direction.

Comment
Add comment · Show 1 · 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 sysameca · Jun 06, 2014 at 03:44 PM 0
Share

Yes that is exactly what i needed.Works like a charm.Thank you very much!I need to study more linear algebra to get my things straight.

avatar image
0

Answer by robertbu · Jun 06, 2014 at 02:31 PM

I think this gives it to you:

 var v = Vector3.cross(n,ray.direction);
 var direction = Vector3.cross(v,n);

You may have to reverse the order of the parameters of the second Cross.

Comment
Add comment · Show 1 · 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 sysameca · Jun 06, 2014 at 02:57 PM 0
Share

No it does not work.It does something else that it's not on the graphed results.Let me put it up again: I need the perpendicular of the normal (N) to point in the direction which the ray is.

For instance the pependicular of the hit normal is: Vector3(-hit.normal.y, hit.normal.x) * -1; or Vector3(-hit.normal.y, hit.normal.x); I want to find which one of those should it be used, depending on the casted ray's direction.

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

23 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

Related Questions

exact vector reflection along collision normal vector 1 Answer

Custom gravity based on normal vector and rigidbody.addForce 2 Answers

How to find perpendicular line in 2D? 3 Answers

Generate cylindrical mesh around 3D Catmull-rom spline 1 Answer

How to get the normal of a line in relation to a specific point in 3D? 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