#Mirroring a 2d point on from another 2d point.

1 messages · Page 1 of 1 (latest)

lost turret
#

Hi! im trying to mirror a point on a 2d plan using another point....

#

I tried using the angle between the two and the distance, but i cant seem to make it work...

azure sand
#

Should work the same for directions and points

lost turret
#

it has no explanation on how to use it lol

azure sand
#

Reflects a vector off the vector defined by a normal.

#

That's exactly how to use it. The normal is like the surface of whatever you're reflecting off of

#

So if it's a table top the normal is up

lost turret
#

so like 90 degrees to both of the points?

azure sand
#

No. It's going to be coplanar, but that's beside the point

lost turret
#

so how do i define it?

azure sand
#

Like I said, the normal is like the direction the surface is pointing. Like a mirror

lost turret
#

i dont get how do i define the normal?

#

and what is the angle?

azure sand
#

Thinking about this though you might need to do this in local space

lost turret
#

how do i define a vector with it in genral...

#

i do need it in local space

azure sand
#

Well, you want a mirror a vector across another point right?

lost turret
#

yes

azure sand
#

You need to find out what axis you want it mirrored across

lost turret
#

i got the angle between the two points?

azure sand
#

No, you don't need that

#

Imagine putting up a mirror so the reflection of the point appears where you want it

#

It'll be exactly in the middle right?

lost turret
#

yes

#

what now?

azure sand
#

The direction the surface of the mirror is pointing is the normal

lost turret
#

ok, but how is it defined?

azure sand
#

It's a Vector2

lost turret
#

that i get by doing what though?

#

can we vc?

#

maybe ill understand better

azure sand
#

Sorry, can't do that rn

lost turret
#

ok

azure sand
#

But it depends on what you want to do with it

lost turret
#

ok ill show you

azure sand
#

Vector2.Up or Vector2.Right are both valid

#

But collisions also give you normals you could use to bounce like a laser

lost turret
#

i want to calculate the position of c

azure sand
#

Ok I think I misunderstood

#

Do you know how to get the direction from the ghost to the point?

lost turret
#

vector2.angle?

azure sand
#

No
It's endPosition - startPosition

#

It'll give you a new Vector2

#

Add the result of that to the position in between

lost turret
#

endPosition being the point C?

#

ghost -a

#

mid -b

#

target -c

azure sand
#

We're trying to find c

lost turret
#

yes

azure sand
#

In this case endPosition is the mid point

lost turret
#

so, endPosition + (endPosition - startPosition )?

azure sand
#

For this yes. endPosition - startPosition is a common formula though, so it's good to remember

lost turret
#

i legit did that allready, but i wrote it with a mistake

#

it works

#

thank you very much

azure sand
#

Np

#

It's the little things that give us the biggest headaches :p

lost turret
#

true, i was on that for an hout

#

hour

#

so simple ....