You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
You can write your topic however you want, but you need to answer these questions:
I don’t really understand what you’re asking. You want to get the direction between the two average points in the top-left?
Just to clarify – you’re trying to obtain these two green points given the two yellow ones (the higher one is obtained from the average of point 0 and 1)
yes, I want a function that lets me input a point(from a table of points), the average of the table of points in position, and the goal.
Ok, I think I understand
-- 1. get the average
local average = 0.5 * (p0 + p1)
-- 2: get the direction from the average to our new supposed part; direction = goal - origin
local averageToDir = (dirPoint - average).Unit
-- 3: get the vectors perpendicular to `averageToDir`, we just swap x and y axes, but use negative y for the x axis. in the workspace we would use Z instead of Y
local perpendicularToDir = Vector3.new(-averageToDir.Z, 0, averageToDir.X)
-- 4: now that we have the vector perpendicular to `averageToDir`, to get the direction from `dirPoint` to the new p0 and p1, we add and subtract `perpendicularToDir` respectively
local newP0 = dirPoint + perpendicularToDir
local newP1 = dirPoint - perpendicularToDir
-- 4.1: optionally, we can multiply perpendicularToDir by our original p0 and p1's magnitude so newP0 and newP1 have the same distance as the original p0 and p1:
local halfDist = (p0 - p1).Magnitude * 0.5
local newP0 = dirPoint + perpendicularToDir * halfDist
local newP1 = dirPoint - perpendicularToDir * halfDist
When implemented it should give you a result like this, hopefully it’s what you’re asking for:
yes, ty Roblox charlimit Roblox charlimit
and how would I know if it was to the left or right of the average?
In world space? You can just compare the X axis. If x < average.X then it’s to the left, otherwise it’s to the right.
I would assume this isn’t what you mean though, can you give some examples for what you’d consider left or right?
I want to know wether to add or subtract perpendiculartodir. I also want to know what every variableis, specifically p0 and p1, where do they come from? I’m going to have a table of points that I want to move, I’m going to calculate their positions one at a time. The average will be off all the points. the points will not always be in line, just dotted around randomly