CFrame being annoying, Read post for more info

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

1 Like

I don’t really understand what you’re asking. You want to get the direction between the two average points in the top-left?

1 Like

image

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)
image

1 Like

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:
Medal_YlryLJ0YrK-ezgif.com-optimize

1 Like

yes, ty Roblox charlimit Roblox charlimit

1 Like

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?

1 Like

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