Generating Corner points of Rectangular Box using center point and forward vector - Printable Version +- iDevGames Forums ( http://www.idevgames.com/forums)+-- Forum: Development Zone ( /forum-3.html)+--- Forum: Game Programming Fundamentals ( /forum-7.html)+--- Thread: Generating Corner points of Rectangular Box using center point and forward vector ( /thread-3745.html) |

Generating Corner points of Rectangular Box using center point and forward vector - 3DPat - Nov 9, 2006 01:01 AM
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 Generating Corner points of Rectangular Box using center point and forward vector - Fenris - Nov 9, 2006 04:18 AM
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. Generating Corner points of Rectangular Box using center point and forward vector - TomorrowPlusX - Nov 9, 2006 09:00 AM
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. Generating Corner points of Rectangular Box using center point and forward vector - 3DPat - Nov 10, 2006 04:26 AM
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 Generating Corner points of Rectangular Box using center point and forward vector - OneSadCookie - Nov 10, 2006 04:42 AM
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. Generating Corner points of Rectangular Box using center point and forward vector - Fenris - Nov 10, 2006 05:47 AM
Also, just need to point out that my solution does not require any trigonometry. Just simple vector adds and scalar multiplications. Generating Corner points of Rectangular Box using center point and forward vector - 3DPat - Nov 13, 2006 09:40 PM
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 |