#Math Question: Getting 2x 3D points with radius from center

1 messages · Page 1 of 1 (latest)

timid hill
#

Could you clarify? "Points" by definition are only a position; they cannot "face" anything.

Based on your question, I would assume that you have two points (let's call them a and b), a radius (r) and a direction (d) in which your start and end points (s, e) are offset.
In that case, getting s and e would simply be a matter of calculating
s = a + (d.normalized * r)
and likewise for e, with a changed for b.

long scaffold
#

Yeah I'm very confused

sharp umbra
#

hmmm yeah.... i doubt i can give a better explanation 😄

known, 2x 3D world positions( black dots )

now lets say this position has a quad facing( the black outlined circle for that matter, also representing the radius ) the other world position
within a radius, i want a starting position, that will then draw a straight path to the ending position

does that help?

long scaffold
#

Zenvin gave the solution

sharp umbra
#

ok, just wanted to give more details just try to help clarify more

long scaffold
#

er wait

#

it's going to be p2 - p1 + start

#

where p1 and p2 are those center points

#

and start is at some distance away from p1

sharp umbra
#

so could you reformat that for me because i am way in over my head

long scaffold
#

p1 and p2 are black dots

#

start is starting position

sharp umbra
#
 public static void CalculatePositions(Vector3 p1, Vector3 p2, float radius, float distanceFromP1, out Vector3 startingPosition, out Vector3 endingPosition)
    {
        // Calculate the direction vector from p1 to p2
        Vector3 direction = (p2 - p1).normalized;

        // Calculate the starting position
        startingPosition = p1 + direction * distanceFromP1;

        // Calculate the ending position
        endingPosition = startingPosition + direction * radius * 2; // Assuming you want to move twice the radius from the starting position
    }

i put this convo into chatGPT and he created this
is that anywhere close? 😄

long scaffold
#

I refuse to look at chatgpt code on this server

sharp umbra
#

ok, ignore that last... i came up with this code snippet, but i suck at math, how am i doing?

#

🤷‍♂️

long scaffold
#

why do you have distance from p1 as a param

#

don't you always want it at p2?

#

like you'd never want the point halfway between p1 and p2

sharp umbra
#

sigh...

long scaffold
#

?

sharp umbra
#

I should have added to my question that this is a spoon fed question, because i do not have the skills to "work it out" myself

long scaffold
#

spoon feeding is also something we don't do on this server

sharp umbra
#

Thanks for your time, i will wait for someone who understands my dependable position

long scaffold
#

no problem. im happy to help you understand more or direct you to resources