Vector Math Problem

I know point(0,0,0) and point(0,2,0) and point(1,1,0) and point(2,0,0).

I am trying to work out - given the above - what point(?,?,0) is?

I’m new to vector maths and although I’ve been using the math tutorials and cheat sheet, I can’t work out how to do this.

I have found:

  • The direction and distance or length from point(0,0,0) to point(0,2,0)
  • The direction and distance or length from point(0,0,0) to point(2,0,0)
  • The direction and distance or length from point(0,0,0) to point(1,1,0)

Can someone clarify what I need to do to find point(?,?,0) please?

Thank you.

You know that your Vectors (2,0,0) and (0,2,0) are 2 units long. What you want is a vector pointing towards (1,1,0) that is also 2 units long.

So you first take your vector (1,1,0) and let JME normalize it. This generates a vector, which is exactly 1 unit long.

Then you can multiply the genrated vector by 2 to get your result:

new Vector3f(1, 1, 0).normalize().mult(2.0f);

Thank you very much for the suggestion, however wouldn’t that result in point(2,2,0) when it should be something like point(1.4,1.4,0) approximately?

My apologies for doubting you - it works perfectly. I confess that I don’t understand how it works but it works.

Thanks again :slight_smile:

Well the thing you probably missed was that while this vector (1,1,0) has two components that are 1 unit long, its entire length is the square root of both components squared, which is in this case about 1.41 (Sqrt(2)). When the vector is normalized this whole length is shortened to 1 and the components become shorter than 1 unit.

Your example:

Starting vector:
(1,1,0), length = 1.41

(0.7,0.7,0), length = 1

Times two:
(1.4,1.4,0), length = 2 (times your circle’s radius)

I hope this helps you understand :smiley:

1 Like

Ahhhhhhhhh :smile: This is what I enjoy about JME3 and the community - I learn something new every day.

Thank you both for the solution and the explanation. I understand perfectly now although I think completing the Khan Academy Geometry and Trigonometry courses would be a smart move on my part. School was a long time ago for me :wink:

Thanks again to both of you.

This also might be useful:

…linked at the top of every page here if you lose the link.

1 Like

Thank you for the link.

You could use interpolate, I dont like this function because it changes the parameter, but you can allways look at the code and create an similar function:

        Vector3f va = new Vector3f(0,2,0);
        Vector3f vb = new Vector3f(2,0,0);
        Vector3f vc = va.clone().interpolate(vb, 0.5f).normalize().mult(va.length());

…which is why it was renamed in 3.1.

But interpolate is the slow way to go in this case. If you want a midpoint then just take the midpoint:

Garbage-friendly version:

1 Like

Also… this will not do what you expect it to. You want to pass 0.5 for ‘half way’.

True, I think I just wrote it too fast, fixed now.