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: How to find A and B (pythagorean theorem)

Previous Thread :: Next Thread 
97neko is not online. 97neko
Joined: 14 Sep 2014
Total Posts: 16159
07 Jun 2015 06:55 PM
if you have the hypotenuse and all angles

無料の魂
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
07 Jun 2015 06:56 PM
function Pythagorean_Theorem(a,b,c)
return (a ^ 2) + (b ^ 2) == (c ^ 2)
end


I think this would work.

a = First Leg
b = Second Leg
c = Hypotnuse
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Jun 2015 06:57 PM
cos(angle) = adj/hyp
adj = hyp*cos(angle)

sin(angle) = opp/hyp
opp = hyp*sin(angle)
Report Abuse
97neko is not online. 97neko
Joined: 14 Sep 2014
Total Posts: 16159
07 Jun 2015 06:57 PM
um, i have the hypotenuse and the angles

無料の魂
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
07 Jun 2015 06:59 PM
function Pythagorean_Theorem(a,b)
if tonumber(a) and tonumber(b) then
return (a ^ 2) + (b ^ 2)
end
end

This will get the hypotnuse I think. I may be forgetting square root stuff.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Jun 2015 06:59 PM
fish, he HAS the hypotenuse and the angles
HAS, like you know, he KNOWS what they are
Report Abuse
97neko is not online. 97neko
Joined: 14 Sep 2014
Total Posts: 16159
07 Jun 2015 07:01 PM
@cnt,
what angle do i plug in

無料の魂
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
07 Jun 2015 07:02 PM
So you want to find what numbers will make a right triangle with the hypotnuse?
Report Abuse
97neko is not online. 97neko
Joined: 14 Sep 2014
Total Posts: 16159
07 Jun 2015 07:03 PM
yes

無料の魂
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Jun 2015 07:04 PM
You can plug in any angle, it will give you the side lengths adjacent to that angle and opposite (so don't get confused)
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
07 Jun 2015 07:06 PM
\ A
|\
B |-\ C

Let's say you've got triangle ABC; as shown above.

You know ∠A, ∠B, ∠C, and AC.
For reference, a lowercase letter is the opposite of the uppercase angle. (i.e. a is opposite ∠A).


a = AC * cos(∠C)
b = AC
c = AC * sin(∠C)


Hope this helps.
Report Abuse
97neko is not online. 97neko
Joined: 14 Sep 2014
Total Posts: 16159
07 Jun 2015 07:19 PM
well, actually, this is what i have:
prntscr[DOT]com/7edhtj

I'm trying to set the bar to the hypotenuse, and I create the initial bar along the bottom line with the length of the hypotenuse, but because of how roblox rotates things, it will put part of the bar below the bottom line and part of it above, and it will also move it together, so i will need to get the hypotenuse positioned in the correct area.

I was going to try to get the A and B of half of the hypotenuse, since it is essentially being cut in half and move it up 'A' pixels to position it correctly, but it didn't work.

Wot do.

無料の魂
Report Abuse
97neko is not online. 97neko
Joined: 14 Sep 2014
Total Posts: 16159
07 Jun 2015 07:23 PM
local EquipUi = function()
coroutine.resume(coroutine.create(function()
local bar = Instance.new('Frame',plr.PlayerGui.HUD.UI)
local final = Instance.new('Frame',plr.PlayerGui.HUD.UI)
bar.BackgroundColor3 = BrickColor.new('Institutional white').Color
final.BackgroundColor3 = BrickColor.new('Institutional white').Color
bar.BorderSizePixel = 0
final.BorderSizePixel = 0
final.Name = 'final'
while wait(1/60) do
local abS = plr.PlayerGui.HUD.UI.AbsoluteSize
local convPos = UDim2.new(0,abS.X * .15,0,abS.Y * .74)
local pos,bool = camera:WorldToScreenPoint(tool.Barrel.Position)
local m = ((pos.X-convPos.X.Offset)^2+(pos.Y-convPos.Y.Offset)^2)^0.5
local s = (pos.Y-convPos.Y.Offset)/(pos.X-convPos.X.Offset)
final.Rotation = math.deg(s)


local adj = math.cos(math.deg(s)) * m/2
local opp = m/2 * math.sin(math.deg(s))

opp = opp

final.Size = UDim2.new(0,m,0,1)
final.Position = UDim2.new(0,convPos.X.Offset,0,convPos.Y.Offset-opp)
bar.Position = UDim2.new(0,pos.X,0,pos.Y)
end
end))
end

無料の魂
Report Abuse
CrowClaws is not online. CrowClaws
Joined: 04 Jul 2010
Total Posts: 4466
07 Jun 2015 07:26 PM
learn trig pl0x
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