0 votes

Basic Diagram A

Basic Diagram B

Hopefully I can explain this succinctly. I have two points Point A (Blue) and Point B (Red.) I'm trying to figure out how I would go about finding the "inverse" coordinates, which would result in Desired Point (White.) If the blue point was elsewhere, then the white point would also be elsewhere, but always at the same distance, and at the same angle.

I'm sure I'm just not fluent enough in Vector maths, or maths, to figure it out. I have tried get the angle from Point A to Point B. Then I thought I could rotate that angle 180 degrees, and use the difference between Point A and B as the distance to the new point, but it don't seem to be as simple as that.

I hope I'm making sense....and apologies for the cheap diagrams.

Godot version 3.3
in Engine by (14 points)

1 Answer

+1 vote

I'm sure there's a better way to do it but:

func get_negative_vector(origin_vector, destination_vector):
    return (destination_vector - origin_vector).tangent().tangent() + origin_vector 

I'm considering origin_vector to be your Point A and destination_vector to be your Point B. Basically, I get the line segment between the two points, rotate it 180 degrees and add it to Point A.

by (3,389 points)

Wooo, that's beautiful! Thank you so much, it works perfectly. Just gonna make sure I understand exactly what is going before I move on. Very much appreciated!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.