Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Help with vectors

Author
Message
Brightside_
5
Years of Service
User Offline
Joined: 27th Oct 2013
Location:
Posted: 28th Jul 2018 19:36 Edited at: 28th Jul 2018 19:41
Hi people!
I have vertex position .xyz and vector which have direction out of it

Now I need to create vector which will be offseted by previous direction and pointed to original vertex
I get new position like this:
tPos.x=VertexPosition(v).x+tVector.x*RayLength
tPos.y=VertexPosition(v).y+tVector.y*RayLength
tPos.z=VertexPosition(v).z+tVector.z*RayLength
And new vector like this:
tVector.x=tVector.x*-1
tVector.y=tVector.y*-1
tVector.z=tVector.z*-1
But I seems it is not correct..
What I do wrong?
revenant chaos
Valued Member
12
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 28th Jul 2018 23:17 Edited at: 28th Jul 2018 23:22
Hi Brightside,
Is your input vector normalized?

The vector is multiplied by RayLength when calculating the new position, this seems to indicate the vector is of unit length and must be scaled in order to span from A to B.
However the input vector is merely inverted to calculate the new vector, indicating that the input vector is of non-unit length and already spans from A to B.


If the input vector already spans from A to B, the solution is to remove *RayLength when calculating the new position.


If the input vector is unit length, the solution is to add *RayLength when calculating the new vector.
Brightside_
5
Years of Service
User Offline
Joined: 27th Oct 2013
Location:
Posted: 29th Jul 2018 01:39
@revenant chaos
Direction vector is normalized, position vector is not.
Generally I try to find snippet to set vector(position .xyz and direction .xyz) which starts in point A and look at point B
It is like
position object x1,y1,z1
point object x2,y2,z2
I'm not sure how to set vector direction here

Login to post a reply

Server time is: 2019-10-17 23:31:47
Your offset time is: 2019-10-17 23:31:47