Getting slope anlge of a wedge

I just needed to know if it was possible to get slope angle of a wedge part


as you can see here what I want to get is what is written on the wedges, but I couldnt find something that might get to that result

this is my function

local function getAngle(normal)
	return math.deg(math.acos(normal.Y))
end

what I want to achieve is to make sure when a wedge is over n degrees it becomes a cliff.

2 Likes

it should be atan(part.Size.Y/part.Size.Z)

2 Likes

well, that’s doesnt work. It just takes as reference the size of the triangle, but not the actual rotation, so everytime it gets a random angle

1 Like

you never mentioned anything about orientation, what exactly are you trying to do?

1 Like

uhhh, 1. the title 2. the function’s name 3.the wedges images have degrees?

I need slope angle

1 Like

yeah… the angle of the slope of a wedge (i.e. a triangle) is the inverse tangent of its dimensions, which is apparently not what you are looking for.

i truly have no idea what you are looking for that’s why i’m asking more specifically what you are trying to do

Well, you should be using the properties of SOHCAHTOA, which is how you would get missing angles/sides for right triangles. (Like the wedge here) This is an example of exercising simple trigonometry formulas. For this one, since you want to get the “slope” or the hypotenuse of the wedge, you would use TOA.

local function getAngle(wedge)
	local opposite = wedge.Size.Z
	local adjacent = wedge.Size.Y

	local hAngle = math.atan(opposite / adjacent)
	local hInDeg = math.deg(hAngle)

	return hInDeg
end

Hope this helps, and good luck on your developing journey! :smiley:

1 Like

wait, you made me realize that I just didnt explained really well what I need to achieve.
what you are trying to do here is finding the slope angle depending on the wedge’s size, but I want to find the slope angle depending on world axis. Here’s an example

so, I have 3 points


Now let’s make a plain (not necessary but just for explaining)

and a line that goes perpendicular to it

now here I need this angle

I hope this explainging helps

r u trying to make sliding work with slopes? she just answered ya with exactly what u gon need

actually not (just tried both the solution and none worked

if someone needs why I’m using ths then I need cliffs here

do u know the thing for G = bar{(A, 1), (B, 1), (C, 1)} thats like the center of the triangle u could make a vecor that goes through that point and some other point, calculate it from the origin position and do stuff with that atan calculations yabadabadu

and what I need is all the calculations (I’m not in high school so I still dont know a lot of all the math stuff), then everything should be done. Also an idea is to use a raycast.Normal

You have 3 points, use those 3 points to generate 2 vectors, it doesn’t matter which points are used in which order (let’s call V1 and V2).

Perform a cross product to get the perpendicular vector V3.

V3 is made up of X, Y, Z

Since you’re comparing the angle to the horizontal plane, you just need to separate V3 into 2 vectors: 1 for horizontal and 1 for vertical, then you can use trig to get the angle of V3 to the horizontal plane.

V3’s angle doesn’t represent the angle that you want in your drawing, it’s actually the 90 degrees complement of it, so just subtract it from 90 degrees.

Let V_horizontal = (X, 0, Z) of V3
Let V_vertical = (0, Y, 0) of V3

angle = 90deg - atan( ||V_vertical|| / ||V_horizontal|| )

local point1 = Vector3.new() -- one of the blue points
local point2 = Vector3.new() -- one of the blue points
local point3 = Vector3.new() -- one of the blue points

local V1 = point2 - point1
local V2 = point3 - point1
local V3 = V1:Cross(V2)

local V_horizontal = Vector3.new(V3.X, 0, V3.Z)
local V_vertical = Vector3.new(0, V3.Y, 0)

local angle = math.pi/2 - math.atan(V_vertical.Magnitude / V_horizontal.Magnitude) -- final angle to be used in radians
local angleDegrees = math.deg(angle) -- convert angle to degrees form

Note: V3 may point in either direction of the green line depending on how you set up your V1 and V2, but it should still give you the right angle in the end.

2 Likes

actually yes, that’s was I was searching for! This really helped me a lot and I appreciate your interest on this post.

(for who’s trying to find slope anlge of the SIDE of the wedge go read post 7)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.