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
 

Re: Math

Previous Thread :: Next Thread 
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
01 Aug 2015 03:41 PM
I have a circle. I need to tell if the point is outside the circle, and then reposition the point so that it will be on the circle (and on the same line).
directdist is the hypotenuse (calculated with pythagorean theorem)
the radius is 151
local angle = math.tan(dist.X / directdist)
local x = center.X + (151 * math.cos(angle))
local y = center.Y + (151 * math.sin(angle))

This is giving me some whack results, anybody know why?
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
01 Aug 2015 03:52 PM
bump
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Aug 2015 04:08 PM
You use atan to get an angle, not tan.
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
01 Aug 2015 04:14 PM
ah thank you
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Aug 2015 04:15 PM
Also you don't use atan if you have the adjacent side and the hypotenuse, you use acos.
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
01 Aug 2015 05:10 PM
So the adjacent is the X axis, right?
I'm still having problems with it.
http://pastebin.com/ynaZJKYG
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Aug 2015 05:12 PM
What are you doing here:
'if angle <= 0 then
local angle = math.atan(dist.X / 151)' ?

First of all, it's impossible for that to happen. And can you provide screenshots?
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
01 Aug 2015 05:15 PM
actually nvm
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
01 Aug 2015 05:15 PM
I think I may have figured it out, but I'll post again if it doesnt work.
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
01 Aug 2015 05:16 PM
cool

i dont know what

acos
atan
tan
cos
sin
asin

does
Report Abuse
morash is not online. morash
Joined: 22 May 2010
Total Posts: 5834
01 Aug 2015 05:18 PM
They calculate things with angles.
Report Abuse
lostend is not online. lostend
Joined: 21 Aug 2011
Total Posts: 8265
01 Aug 2015 05:19 PM
^im only in 7th grade(going into 8). ):

i went on youtube and got a brief explanation of what it is. but i dont know what if can be used for
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
01 Aug 2015 05:19 PM
So it didn't work. I took out the condional and made the X value negative to flip the axis (it was backwards). At this place there is a reticle on the circle and it follows the X axis of the mouse while sticking onto the edge of the circle, then when the mouse is above the center, it doesn't move at all.
http://www.roblox.com/games/276592059/t
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
01 Aug 2015 05:20 PM
lost I'm a rising freshman and I haven't taken trig/geometry yet so I just googled things too - not entirely sure what im doing lol
Report Abuse
lostend is not online. lostend
Joined: 21 Aug 2011
Total Posts: 8265
01 Aug 2015 05:22 PM
oo nice. might search up some explanations too.
i mostly haven't learned it because i havent had a reason to use it yet
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
01 Aug 2015 05:23 PM
This is the code that moves the reticle (its the white square not the one in the center)
if directdist > 151 then
local angle = math.atan(dist.X / 151)
local x = center.X + (151 * math.cos(angle))
local y = center.Y + (151 * math.sin(angle)) - 20
gui.test.Position = UDim2.new(0,x,0,y)
print(gui.test.Position)
elseif directdist < 16 then
print("inside")
dist = Vector2.new(0,0)
end
Report Abuse
morash is not online. morash
Joined: 22 May 2010
Total Posts: 5834
01 Aug 2015 05:24 PM
I'm pretty sure this will give you the affect your looking for:

radius = 151
local angle = math.atan2(dist.Y - center.Y, dist.X - center.X) --If you haven't already subtracted the center from dist
local x = center.X + (radius * math.cos(angle))
local y = center.Y + (radius * math.sin(angle))
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
01 Aug 2015 05:25 PM
Why are you even getting the hypotenuse in the first place anyways c:
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
01 Aug 2015 05:29 PM
Yeah it worked - thanks. Would you care to explain what you did differently?
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
01 Aug 2015 05:31 PM
well y'see I need to get the magnitude of the mouse from the center. But then I looked up some trig stuff and sohcahtoa so to get the angle between the hypotenuse and the adjacent I used the cosine - I'm not entirely sure what I'm saying right now but that was my reasoning
Report Abuse
FactualTheory is not online. FactualTheory
Joined: 10 Sep 2013
Total Posts: 1365
01 Aug 2015 05:32 PM
The hipotenuse is for triangles

genius

Look for the radius or some sht

And do DistanceFromCharacter lol

Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
01 Aug 2015 05:35 PM
lmao what are you talking about
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
01 Aug 2015 05:35 PM
http://wiki.roblox.com/index.php?title=Magnitude
Report Abuse
FactualTheory is not online. FactualTheory
Joined: 10 Sep 2013
Total Posts: 1365
01 Aug 2015 05:36 PM
the length of the hipotenuse is the square root of the other two sides of the triangle together, genius.

Go back to 7th grade lol.

Just use DistanceFromCharacter it creates a sphere around the part you are using.

(A sphere as in an invisible one.)
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
01 Aug 2015 05:37 PM
oh i dont have to use that hypotenuse function - thanks for helping me rrealize that
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