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
1
Question by Fotal · Feb 03, 2021 at 10:25 AM · trigonometry

Calculate new point by Normal vector

Hi all! I need to apply an offset (AK, KC) to point A, i.e. Vector2d and do it perpendicular to AB as it shown on the picture.

alt text

applicationframehost-2021-02-03-11-15-25.png (33.7 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
3
Best Answer

Answer by Bunny83 · Feb 03, 2021 at 10:53 AM

So this is a 2d problem, right? Because otherwise your distance AK would trace a circle around the normal. So K wouldn't be a point but a circle. So in case we talk about 2d it's actually quite simple. First get your normal vector AB and normalize it. So our normal points towards B. To get the perpendicular to your normal all you have to do is rotate the normal by 90° this is super simpler in 2d because a 90° rotation just means swapping the two components and inverting one of them. Which component you invert dictates the rotation direction. Since we need a counter-clockwise rotation we just do:

 Vector2 n = (B - A).normalized;
 Vector2 p = new Vector2(-n.y, n.x); // 90° counter clockwise rotation

With those two vectors it's just ordinary vector addition:

 Vector2 C = A - n * KC + p * AK;

This should give you the point you're looking for.

Note if you need this in a 3d environment you need to specify more data as the problem is not solvable with the current information.

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 Bunny83 · Feb 03, 2021 at 11:03 AM 0
Share

In your particular case the point C would be (4.2, 5.4) unless I made a mistake ^^ Did the calculations in my head

avatar image Llama_w_2Ls Bunny83 · Feb 03, 2021 at 11:18 AM 1
Share

Of course you did them in your head Bunny, you blim$$anonymous$$ genius

avatar image Bunny83 Llama_w_2Ls · Feb 03, 2021 at 12:18 PM 1
Share

:D actually I did. Currently I don't have Unity or a calculator at hand. I just through about it and realised that the vector AB has components 3 and -4. So the length of that vector is 5 (you know 3-4-5 right triangle so 3²+4² ==25 --> 5) So the normalized version of AB is just (3/5,-4/5)== (0.6, -0.8). The rest is just simple multiplication and addition. I do admit that I write down intermediate results here in the text field ^^.

Without the 3-4-5 shortcut this would be almost impossible because who can calculate square roots of non square number in the head? ^^

avatar image
1

Answer by jackmw94 · Feb 03, 2021 at 10:52 AM

Since you know AK and KC then you can determine AC, which is AK + KC.

Then to find the coordinates of C, you can do A + AC = C.

Add a comment if I have misunderstood this :)

Comment
Add comment · Show 6 · 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 Llama_w_2Ls · Feb 03, 2021 at 10:55 AM 0
Share

I don't understand the last calculation. How can you add a vector to a point?

avatar image Llama_w_2Ls Llama_w_2Ls · Feb 03, 2021 at 10:56 AM 0
Share

AC doesn't give you the x and y position. Doesn't it just give you the magnitude?

avatar image jackmw94 Llama_w_2Ls · Feb 03, 2021 at 11:08 AM 2
Share

It's very possible I'm having an absolute mare with this but:

A is a point at (2, 5)
AB is a vector offset of (3, -4)

To find coordinates of B you do A + AB
B = (2, 5) + (3, -4) = (5, 1)

I imagined AC would be the vector from point A to point C, which you can find by adding the vectors from points A to K and K to C. Therefore the coordinates of C would be A + AC like how we found B's coordinates from A + AB.

Plz let me know if I'm being an idiot :D

avatar image Bunny83 jackmw94 · Feb 03, 2021 at 11:15 AM 1
Share

I think the confusion is that in math we usually write points and vectors between points with capital letters. So A, B, C and K are points while AB is the vector from A to B. I think what the OP meant to say is that |AK| and |KC| are known, not the actual vectors. At least that's what I can read out of the image since it just says "AK = 2" and "KC = 1"

Show more comments
avatar image Bunny83 · Feb 03, 2021 at 11:02 AM 0
Share

As I understood the problem, his AK and KC are not known vectors but just the lengths of those vectors. $$anonymous$$aybe I got it wrong, but if the Vectors AK and KC are known, yes, then it's just the addition of those 3 vectors.

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

111 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 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 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 avatar image avatar image avatar image

Related Questions

Trig function problem 1 Answer

simulate a circle move 2 Answers

How should I calculate an 8-directional animation based on 360 degree rotation around the player using raycast? 0 Answers

Finding coordinates based on an angle and distance? 3 Answers

Get X,Z coordinates based on origin and angle 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