I'm sure most of you know what that is, if not I could give an explanation.
a^2 + b^2 = c^2
Here is a definition of it.
"In mathematics, the Pythagorean theorem—or Pythagoras' theorem—is a relation in Euclidean geometry among the three sides of a right triangle. It states that the square of the hypotenuse is equal to the sum of the squares of the other two sides" (I got this from the Wikipedia.)
c is the side across from the right angle being the hypotenuse.
Say I lean a part at an angle against a wall in roblox, I want to find the hypotenuse.
My first question is, how would I even begin measuring? would I go by studs??
So if we are doing studs then here is another example.
I want to find the distance across a square shaped part.
Each side of the square is 1 stud long.
Step 1. a^2 + b^2 = c^2
Step 2. 1^2 + 1^2 = c^2
Step 3. 1 + 1 = c2
Step 4. 2 = c2
Step 5. c2 = 2
Step 6. c = (SquareRootSymbol)2 = 1.4142... (The answer)
What I am trying to do is make a roblox defined equation for automatically finding the hypotenuse for a part on roblox. Either it be a triangle or just a square part. What should I do to make it fully functional? and transfer a^2 + b^2 = c^2 to roblox form? Sort of like a Pythagorean theorem calculator.
Imagine a box get cut in half, then it will measure the length and the height size. Then square them. THEN it will add the two together giving you the hypotenuse but... the hypotenuse must be square rooted. Then the length across the square will be given.
To create a simple function to do this, you can use this:
function pythag(a, b) return math.sqrt(a^2 + b^2) end pythag(3, 4) --> 5
However, I can't tell if there is more to your question here. If you were to edit your question and include a diagram or something similar, I might be able to help you more effectively.
I used it to find a part's actual velocity through the X & Z plane. In this example, I did this to detect the player's HumanoidRootPart's velocity (walkspeed (if you're walking)).
s = script.Parent repeat wait() until s ~= nil while true do wait() local reference = tostring(math.floor(math.abs(s:findFirstChild("HumanoidRootPart").Velocity.x)))..", "..tostring(math.floor(math.abs(s:findFirstChild("HumanoidRootPart").Velocity.y)))..", "..tostring(math.floor(math.abs(s:findFirstChild("HumanoidRootPart").Velocity.z))) game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextLabel.Text = reference local ok = math.floor(math.sqrt(math.pow((tostring(math.abs(s:findFirstChild("HumanoidRootPart").Velocity.x)), 2)+(math.pow(tostring(math.abs(s:findFirstChild("HumanoidRootPart").Velocity.z)), 2))) game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextLabel2.Text = ok end
Lol, so messy... If you want to see the code easier, just copy & paste this to an actual script.
function pytha(a,b,c) end --Something like this, where you can insert your things as a,b, and c. I'm not making the equation for you because I am not sure what you want out of this, but basically you can call the function as below, and insert whatever numbers you want as a,b, and c. pytha(1,2,3)