Public Group

# moving a 3d object vector from one place to another by a angle and speed

This topic is 3029 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi all, I am trying to understand how to move a object from one place in 3D space to another 3D point in 3D space by only supplying the angle and speed to move at. The basics I have is to have a vector3D which has x,y,z cords (floats). and from this website, I think that to find out one 3D angle from another would float angleDifference(vector3D other) { double dot1Horizontal = other.x * this->x + other.z * this->z; double dot2Horizontal = other.x * other.x + other.z * other.z; double dot3Horizontal = this->x * this->x + this->z * this->z; double angleCosHorizontal = dot1Horizontal / (sqrt(dot2Horizontal) * sqrt(dot3Horizontal)); return acos(angleCosHorizontal) * (180 / PI); } Vector3D pointA {-1,-1,0}; Vector3D pointB {-1, 1,2} ; printf("angel %f\n", pointB.angleDifference(pointA)); = 63.43... but now how do you convert that angle to move a object in 3D space ?

##### Share on other sites
Is this a 'true' 3-d problem, or is it really a 2-d problem that happens to take place in 3-d space? (Specifically in the xz plane...) I ask because the code sample you posted appears to compute the angle between two vectors as projected onto the xz plane; in other words, there's really no '3-d' involved there.

Also, a direction in 3-d space cannot be fully specified with only a single angle (additional information is needed).

If you're just trying to get from point A to point B though, no angles are necessary - you can simply compute the direction vector from A to B as:
(B-A) / |B-A|

##### Share on other sites
Thanks jyk

I suppose your questions are helping my understand what it is I am trying to do as such.

What the main thing that I am trying to create is a laptop base with a laptop lid opening up, and thus the laptop lid needs to move from the closed position and then to the open position (90 degrees) which is where I thought that I needed the angle to move to. (pivoting on the laptop base back as such)

what does

(B-A) / |B-A|

mean ?

(B-A) /

I get B-A do first, but not sure what |B-A| means ? the | part that is.

so when I want to move from one point to another. I was thinking that if I calculate the arc from the start position and then end position and then move along that arc accordingly to a speed reference. Would that be the way of doing it ?

##### Share on other sites
Hey Genux,

What you are trying to do is rotate an object (your laptop lid) not move it.

Just wanted to clarify that so that you could get better help / find info better for yourself (:

Basically you need to rotate the lid over time along the x axis from 0 to 90 degrees, using the back of the lid (the part that you want to remain still as the lid opens) as the origin for the rotation.

##### Share on other sites
Quote:
 Original post by genux...(B-A) / |B-A|...I get B-A do first, but not sure what |B-A| means ? the | part that is...

Norm/Length of a vector

##### Share on other sites
thanks Anntor for that link to the Normal/Lenght, makes allot more sense now :).

1. 1
2. 2
JoeJ
20
3. 3
4. 4
frob
12
5. 5

• 13
• 19
• 13
• 20
• 13
• ### Forum Statistics

• Total Topics
632194
• Total Posts
3004693

×