Generating Corner points of Rectangular Box using center point and forward vector
Hi all.. Please help me with this!!!
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
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
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.
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.
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.
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
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
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.
Also, just need to point out that my solution does not require any trigonometry. Just simple vector adds and scalar multiplications.
Possibly Related Threads...
Thread:  Author  Replies:  Views:  Last Post  
finding a training center  Heeeelp  Glauter  1  3,583 
Dec 26, 2011 12:30 PM Last Post: zenkimoto 

Generating an Index from a 3d Vector  Oddity007  2  3,110 
Aug 18, 2009 05:38 PM Last Post: Oddity007 

Angle between two points?  Graphic Ace  6  6,222 
Nov 8, 2008 12:11 PM Last Post: macnib 

Good collision points  Skorche  7  5,139 
Sep 22, 2005 09:09 PM Last Post: Skorche 

Algorithm for moving between two points on a plane...  WhatMeWorry  4  5,495 
Aug 23, 2005 11:36 AM Last Post: unknown 