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
0
Question by nameless323 · May 16, 2013 at 01:46 AM · vectorcoordinatespointgeometryalgebra

Calculate point coords which lays on normal vector

Hello. I have A and B points which z coord the same. I need calculate point C coords between this two points and calculate D point coords, which lays on normal vector to AB vector, and on length l.alt text

I can calculate C point coords using A.transform.position + (B.transform.position - A.transform.position) / 2f but how can I do other stuff (calculate D point coords)? (this is 2d game and z coords always 0 for all points) thanks.

image.png (3.9 kB)
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

2 Replies

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

Answer by Prodigga · May 16, 2013 at 02:03 AM

If you get a cross between (B-A) and whatever is the 'up' vector for your points (the vector pointing to you from your screen), then this will give you a vector (which we will call 'N') that points perpendicular to the line A->B. If you normalize 'N', then

D = C + N * distance to D

Comment
Add comment · Show 2 · 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 nameless323 · May 16, 2013 at 03:06 AM 0
Share

Thanks. But can you explain a little bit more about how can I get N vector which will be perpendicular to AB using only world forward direction and A and B coords? Thanks again!

avatar image nameless323 · May 16, 2013 at 03:14 AM 0
Share

Thanks, now I get it =)

avatar image
1

Answer by robertbu · May 16, 2013 at 03:23 AM

As @Prodigga indicates, the cross product is a good way to go to solve this problem. Given you have positions A and position C (which you calculate in your question) here is a bit of code:

 var v3AC = v3A - v3C;
 var v3D  = v3C + (Vector3.Cross(v3AC, Vector3.forward)).normalized;

You can change which side of the line the point is on by either changing the order of the parameters in the Vector3.Cross() or by using Vector3.back instead of Vector3.forward.

Comment
Add comment · 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

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

14 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

Related Questions

Convert 3D model to point cloud - possible? 1 Answer

How to find perpendicular line in 2D? 3 Answers

Move to a clicked point? 1 Answer

Get new Point from Vector and Angle 1 Answer

2D Array for pathfinding 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