generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Angle between two points

Previous Thread :: Next Thread 
Entelicon is not online. Entelicon
Joined: 06 Nov 2012
Total Posts: 1002
03 Aug 2016 05:29 AM
I have two Vector coordinates
a = {5,10}
b = {7,17}

How do I find the angle between those two coordinates?

I've heard the the dot product can help me but it honestly confuses me and I dont know what to do.
Report Abuse
Laedere is online. Laedere
Joined: 17 Jun 2013
Total Posts: 23601
03 Aug 2016 05:36 AM
math.atan2(b[2] - a[2], b[1] - a[1]) * (180 / math.pi)
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
03 Aug 2016 05:38 AM
Since it's 2 2D points, you can use inverse tangent without any effort
puu.sh/qoiqb/c41f86e199.png

You can use atan2 so you can get a range (-pi, pi] or if you add pi: [0, 2pi) instead of a range of (-pi/2, pi/2) using atan.

local angle = math.atan2(b[2] - b[1], a[2] - a[1])
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
03 Aug 2016 05:39 AM
I wrote the coordinates down wrong. I plotted 5, 17; 7, 10 but accidentally put 5, 10; 7, 17.

woops
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image