Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 windexglow · Sep 25, 2010 at 02:15 PM · vector3mathvector2

How to get vector X distance from point on Y angle?

When I modded warcraft3 there was a function called (in jscript syntax) PolarOffset(v : Vector2, distance : float, angle : float) : Vector2

It would generate a point X distance and an Y angle from the input. No matter the angle, it would always be X distance away from the given point.

I've done google searches on it, but it's a wc3-only term so my luck ends there. Does anybody know the proper term for this?

SOLUTION

function PolarOffset(origin : Vector2, distance : float, angle : float) : Vector2{ //o = angle
    var x : float = origin.x + distance * Mathf.Cos(angle * Mathf.Deg2Rad);
    var y : float = origin.y + distance * Mathf.Sin(angle * Mathf.Deg2Rad);
 return Vector2(x,y);
}

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

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by AliAzin · Sep 25, 2010 at 02:50 PM

Take a look at this. You can simply convert between polar and cartesian coordinates.

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 windexglow · Sep 25, 2010 at 09:57 PM 0
Share

function $$anonymous$$rOffset(origin : Vector2, distance : float, angle : float) : Vector2{ //o = angle var x : float = origin.x + distance $$anonymous$$athf.Cos(angle $$anonymous$$athf.Deg2Rad); var y : float = origin.y + distance $$anonymous$$athf.Sin(angle $$anonymous$$athf.Deg2Rad); return Vector2(x,y); } Angle : 0-360

avatar image
0

Answer by windexglow · Sep 25, 2010 at 09:57 PM

function PolarOffset(origin : Vector2, distance : float, angle : float) : Vector2{ //o = angle
    var x : float = origin.x + distance * Mathf.Cos(angle * Mathf.Deg2Rad);
    var y : float = origin.y + distance * Mathf.Sin(angle * Mathf.Deg2Rad);
 return Vector2(x,y);
}

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

Answer by SirGive · Sep 27, 2010 at 09:32 AM

I do believe that logically, you're speaking about the Distance formula.

Distance between two points = squareroot( (x2-x1)(x2-x1) + (y2-y1)(y2-y1) + (z2-z1)*(z2-z1)). If you set a variable equal to that formula, where x1 is the center and x2 is the position your limiting from. You could then rotate x2 based on x1's coordinate system. I hope I am understanding you question.

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

Answer by Proclyon · Nov 16, 2010 at 01:41 PM

Isn't what you mean simply the vector length of the radius of a circle? I have no idea what all this polar stuff is everyone seems to be mentioning. But if angle isn't part of the equasion, just ignore it right? Leaving behind one thing, a 2 dimensional line with a length. So why make it more complex than that, since the angle can't change the length

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

No one has followed this question yet.

Related Questions

how do i keep a gameobject in between the union of 2 or more than 2 circles 0 Answers

Angle between 2 GameObjects and center of screen 2 Answers

Angle between two lines in 2D 3 Answers

Closest point on multiple lines? 2 Answers

Draw line to a specific angle 2 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