function GenerateTriangle(A:Vector3, B:Vector3, C:Vector3)
local center = (A + B + C ) /3
local normal = (B-A):Cross(C-A).Unit
local triOne = script.Triangle:Clone()
local triTwo = script.Triangle:Clone()
triOne.Parent = workspace
triTwo.Parent = workspace
--midpoints
local x = (A + B)/2
local y = (B + C)/2
local z = (C + A)/2
--TY CHATGPT FOR THE MATH FOR POINT β
local v = C - B -- Direction vector of BC
local w = A - B -- Vector from B to A
-- Project w onto v
local t = w:Dot(v) / v:Dot(v)
-- Find beta
local beta = B + t * v
triOne.Size = Vector3.new(0, (A-y).Magnitude, (beta-C).Magnitude)
triOne.CFrame = CFrame.lookAlong(z, (C-beta), (A-beta))
triTwo.Size = Vector3.new(0, (A-y).Magnitude,(beta-B).Magnitude)
triTwo.CFrame = CFrame.lookAlong(x, B-beta, (A-beta))
end
#Generating a Union based off 3 points in space
56 messages · Page 1 of 1 (latest)
I havent done generative stuff like this before so
not sure how helpful ill be
but it looks visually like a formula problem
yea if theres an issue with the math its probably beta
i straight up gave up[ trying to calculate it myself and chatGPT seemed to rpovide something that "works"
give me a min
but how did you handle the floats
they're all numbers
unelss vector3:Cross() rounds them
it should be maintaingin constant precision
is tri1 and tri2 just wedges?
yea
ok
i know certain roblox formulas
auto fuck up
and change to decimals
so lemme check
current issue, preciion is lost at certain angles
yeah ur beta is fucked
never rely on chat gpts
what like the left and right side
idk how you'd use only one triangle
they're never the same unless its a symmetrical
to make a full triangle u need 2 wedges
unless ur doing right triangles
well yeah no shit
then theres ur answer
ur very smart
im silly
indeed
I assumed what he was doing was having 2 unique wedges
not the same
:3
interesting
@manic wadi i neeed to add some edge case detection logic but this so far works much better
local DA_unit = (normal:Cross(C-B) + normal*(normal:Dot(C-B)) ).Unit
local area = 0.5 * ((B-A):Cross(C-A).Magnitude)
local h = (2 * area )/ ((B-C).Magnitude)
local D = A - DA_unit*h --Point D, is point A projeted onto the line BC
i renamed point D to point B
I'm glad you were able to do it!
basically it caclualtes the area of the trianlge given the 3 points, then uses the normal 2D formula to caluate the length then offsets from D
i like how you changed the coloring too. makes your hard work look even more pretty
DA Unit is just BC rotated 90 btw
im surprised the unionAsync keeps the default coloring regions