EClaesson
EClaesson

Reputation: 1618

Calculate direction vector facing origin

I have two vectors defining two separate points in a three-dimensional space. One is static at the origin (0.0f, 0.0f, 0.0f) and the other one will be moving slowly. From this data i need to get a (three-dimensional) direction vector that describes the direction from the moving points current position to the origin.

The moving point will be a directional light (3D game) that always myst face the origin. I don't require any code, just basic information on how to calculate the vector.

Upvotes: 1

Views: 7698

Answers (2)

Orbling
Orbling

Reputation: 20602

If you have a point in space, and you want to know the direction to the origin for it, surely it's just the negative of the point, normalised to unit magnitude if you want a pure direction vector.

Origin <- (x,y,z) = (0, 0, 0) + l(-x, -y, -z)

Upvotes: 5

Michael McGowan
Michael McGowan

Reputation: 6608

I feel like I might be missing something. Do you just want to subtract the moving vector from the origin? If you have a vector (x, y, z), then the vector (-x, -y, -z) should point towards the origin. Am I misunderstanding something?

Upvotes: 6

Related Questions