Generating Corner points of Rectangular Box using center point and forward vector

3DPat
Unregistered

Post: #1

I have a rectangular box, knwing its length,width n height, at origin with some forward vector. This box is translated and oriented in space.

Knowing the forward vector and the center of the cube, how can i calculate the 8 corner points ???

I tried using this... calculating the other 2 perpendicular vectors from the forward vector... then calculating the diagonal vector... but unable to proceed ne further to locate the points on this vector...

Eagerly awaiting some useful reponses

3DPat
Oldtimer
Posts: 834
Joined: 2002.09
Post: #2
You need to know either the box orientation in angles, or the up vector.

If you have the up vector, then you can grab the right vector too, as you said. From these, you can find the midpoints on the box's planes. (Just walk in the direction of all three vectors for the appropriate lengths, in both directions).

From the planes' center points, you can find its corners. For instance, if you use the "up" vector to find the top side, then you you can use the front and right vectors to find one corner. (center point + (front vector * length/2) + (right vector * length / 2). Then you can use different combinations of signs (±front vector, ±right vector) to find the other corners of that side. Then you can just give it a quick thought and see which corners are already calculated and remove any duplicates.
Sage
Posts: 1,199
Joined: 2004.10
Post: #3
Another approach -- which I take -- is if you know the transformation matrix that the box has in world space; you can create your eight corner points in untransformed space ( e.g., where the box would be with an identity transform ) and then transform those eight points by the box's actual transform.
3DPat
Unregistered

Post: #4
Thank you Fenris and TomorrowPlusX for this immediate response...

But i still hav some problems...

TomorrowPlusX .. ur suggestion wud wrk jst perfect in my case... but the problem im facing is tht ... i need to perform these calculations for mobile devices... in this i get the transformation matrix but i cant apply the orientation directly on it. So the problem of orientation still exists...

And Fenris similarly for ur suggestions the problem i face is calculating the angles... coz i want to avoid using Inverse Sine,Cosine calculations... so im still stuck up...

Both ur solutions were just perfect.. but somehow they dont meet the constraints im having... I wonder can it b done somehow just manuplating the Vectors tht i hav and using the length,width n height.

Please do give it a thought...

Thanks again..
3DPat
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
A center and a forward vector do not uniquely specify the orientation of your box. There must be another constraint. Once you decide what that constraint is, either of Fenris' or TomorrowPlusX's solutions will work just fine. Until you decide what that constraint is, you cannot solve this problem.
Oldtimer
Posts: 834
Joined: 2002.09
Post: #6
Also, just need to point out that my solution does not require any trigonometry. Just simple vector adds and scalar multiplications.
3DPat
Unregistered

Post: #7
Hii Fenris,
Thanks for ur replies... using ur technique in the method suggested by TomorrowPlusX helped me solve my problem... it was possible only after calculating the 2nd vector along with the forward vector .

Thankyou all...

3DPat