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
 

Trig help

Previous Thread :: Next Thread 
nighttimeninja314 is not online. nighttimeninja314
Joined: 04 Apr 2011
Total Posts: 4001
24 Jul 2015 10:42 AM
I think I have the math right, but under the condition, it should spit out a 45 degree angle. The following script :

local a,b,c = workspace.A,workspace.B,workspace.C

local adjacent = (a.Position-b.Position).magnitude
local hypotenuse = (a.Position-c.Position).magnitude
local opposite = (c.Position-b.Position).magnitude

local cos = math.cos
local rad = math.rad
local deg = math.deg


local a = deg(cos(adjacent/hypotenuse))

print(" Adjacent:",adjacent,"\n","Hypotenuse:",hypotenuse,"\n","Opposite:",opposite)

print("Angle:",a)



spits this out in the output


Adjacent: 10
Hypotenuse: 14.142135624
Opposite: 10
Angle: 43.558806810558


If somebody could help me out with this, it'd be much appreciated.
Report Abuse
nighttimeninja314 is not online. nighttimeninja314
Joined: 04 Apr 2011
Total Posts: 4001
24 Jul 2015 10:51 AM
bump
Report Abuse
TheAwesomenessDude is not online. TheAwesomenessDude
Joined: 17 Jul 2011
Total Posts: 11602
24 Jul 2015 10:54 AM
using math.acos gives me 45 deg
Report Abuse
nighttimeninja314 is not online. nighttimeninja314
Joined: 04 Apr 2011
Total Posts: 4001
24 Jul 2015 10:57 AM
Thanks!
Report Abuse
nighttimeninja314 is not online. nighttimeninja314
Joined: 04 Apr 2011
Total Posts: 4001
24 Jul 2015 11:14 AM
Oh, had to inverse it.

local a,b,c = workspace.A,workspace.B,workspace.C

local adjacent = (a.Position-b.Position).magnitude
local hypotenuse = (a.Position-c.Position).magnitude
local opposite = (c.Position-b.Position).magnitude

local cos = math.cos
local rad = math.rad
local deg = math.deg


local a = deg(cos(adjacent/hypotenuse))

print(" Adjacent:",adjacent,"\n","Hypotenuse:",hypotenuse,"\n","Opposite:",opposite)

print("Angle:",90-a)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Jul 2015 11:59 AM
acos gets an angle from adj/hyp.

cos(angle) = adj/hyp
acos(cos(angle)) = acos(adj/hyp)
angle = acos(adj/hyp)
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