How to apply this formula?

i wanna make a script where dots move in a heart shape
i have no problem with the moving dots one but my problem is how to apply the formula

The two equations for y in terms of x can be seen there. Once you know that, I assume you can just choose some arbitrary ranges for x and find the y values by plugging x into those equations.

Those equations are only valid on the on the range around [-1.1, 1.1] so you may need to scale the input and output to make your heart the desired size.

1 Like

Hey!

I made this effect work for UI elements because I wasn’t sure what the term “dots” referred to.

Here’s how I did it:

local ScreenGui = script.Parent
local Frame = ScreenGui.Frame
local Size = 10
local Speed = 0.1
local Angle = 0

function Adapt(A)
	local X = Size * 16 * math.sin(A)^3
	local Y = -Size * (13 * math.cos(A) - 5 * math.cos(2*A) - 2 * math.cos(3*A) - math.cos(4*A))
	return ScreenGui.AbsoluteSize.X/2 + X, ScreenGui.AbsoluteSize.Y/2 + Y
end

while wait() do
	local X, Y = Adapt(Angle)
	Frame.Position = UDim2.new(0, X, 0, Y)
	Angle = (Angle + Speed) % (2 * math.pi)
end

Project SOW - Roblox Studio 2024-05-31 00-30-47.mp4 [video-to-gif output image]

EDIT: I added a trail effect to simply visualize the accuracy.

3 Likes

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