Orientating a box to eight points

Member
Posts: 40
Joined: 2002.04
Post: #1
I have a small problem:

I have a physics routine that moves eight particles, arranged in a box shape. Because of the nature of the physics routine, the particles don't necassarily form an exact box, but usually remain in a general box shape.
I have a 3D model of a shopping trolley (dont ask LOL), which I need to allign to the box which best fits the eight points which represent the corners of the trolley.

I hope you all were able to decipher that description-any ideas how I would go about doing this?
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #2
I think since you have 4 edges in each x,y,z direction of local coordinates, it might be a good idea to take the average of those to be the orientation vectos in a box (easily put into a transformation matrix), and take the center to be the average position of the 8 corners. Then scale the local x,y,z coordinate vectors according to your needs, and draw the quads with vertices (1,1,1), (1,1,-1), (1,-1,-1)... (you get the idea), transformed by the generated transformation matrix. Hope this makes sense :?:
Quote this message in a reply
Member
Posts: 40
Joined: 2002.04
Post: #3
Thanks DoooG, but I already have a pre-made model of the shopping trolley, so I'm actually trying to find the correct orientation of the trolley so it best resembles the rotation of the eight particles which form a box. :sorry: sorry, its very confusing isn't it?!

Anyone else have any ideas at all?
Quote this message in a reply
w_reade
Unregistered
 
Post: #4
Well, if you take one corner of the box and get the (normalised) directions to the three closest of the other corners, you should have three (basically) orthogonal vectors, representing the transformed x, y and z coordinates of the trolley. Now find the basis change matrix from the identity matrix to the matrix made of your three transformed vectors (in order), and you have your orientation matrix.

If you don't know how to do a basis change, then tough, I'm afraid. I always hated linear algebra, and even if I wanted to explain it I'd have to learn it properly again, so you'll have to seek details elsewhere. I know for sure there's sample code out there somewhere...

You could probably do it via euler angles or quaternions as well; whatever, the challenge is finding something (or a sequence of somethings) that turns (1 0 0), (0 1 0) and (0 0 1) into [transformedXvector], [transformedYvector] and [transformedZvector] respectively. Doing it backwards and then inverting the sequence might be conceptually easier to work with...

anyway, sorry for gibberish; lunch break over, got to go. Post if you don't get what I'm on about.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
It might be easier to use just four particles (forming a regular tetrahedron) and extract the orientation from those, rather than dealing with the full eight.
Quote this message in a reply
Hog
Member
Posts: 151
Joined: 2002.09
Post: #6
Quote:Originally posted by Cookie
...the particles don't necassarily form an exact box, but usually remain in a general box shape...

so, do you just wan't to rotate the trolley into the right direction, or do you actually want to skew the trolley to the "box"?
it's unclear to me what a general box shape is that doesn't necessarily form an exact box.
Quote this message in a reply
Member
Posts: 40
Joined: 2002.04
Post: #7
Thanks William, I'm pretty sure I understand what you are saying, I'll give it a shot when I get home tonight.

And c_dev, what I meant was that I have eight particles which represent the eight corners of a box. But because of the nature of my physics routine (damping and such), the sides of the box are not necassarily exactly orthagonal. (if that makes any more sense than before Huh ) All I'm trying to do is give the trolley object the same orientation as the box.
Quote this message in a reply
w_reade
Unregistered
 
Post: #8
Hope it helps. BTW, where I mentioned coordinates, I actually meant axes, but I expect you worked that out anyway Wink.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Two gluProject points? mikey 5 5,108 Jan 5, 2012 01:03 PM
Last Post: mikey
  surface rendering from data points mc1961 6 5,105 Nov 15, 2007 03:37 PM
Last Post: TomorrowPlusX
  ordering of control points in glMap1f(...data) WhatMeWorry 10 6,976 Mar 11, 2006 08:36 PM
Last Post: WhatMeWorry
  Cocoa and OpenGL entry points? napthali 5 4,003 Dec 31, 2003 06:22 PM
Last Post: AnotherJake
  Selecting 3D Points BlueAvian 4 2,888 Oct 7, 2003 10:57 AM
Last Post: Johan