   Converting scale between 3D primitive types?
  I wish to change between the following primitives in a game:SphereTetrahedronCylinderBoxCapsuleConeThe problem is that I would like to keep the dimensions/scale constant from one shape to another.If I were to change from a Box to a Sphere then I would take the largest box dimension (x, y or z) and use half of that value to create the sphere.How would you suggest approaching the other not so obvious conversions?  For example, changing between a Box and a Capsule.   
  You'll need to provide more information on what you want the conversions for. Are you looking for constant volume? Do you want to create a bounding shape?EDIT: Actually, your example isn't necessarily "obvious." In your example, you could also take the smallest dimension and create a sphere which would be bounded by the box, instead of vice-versa.   ;Quote:Original post by Spa8nkyThe problem is that I would like to keep the dimensions/scale constant from one shape to another.Impossible to do (as I'm sure you are aware). How can you map a cube (with 3 dof, one in each axis) to a cylinder (2dof)? You can approximate it, but it's always going to be wrong. Having had to do similar things in the past, you can only really do a quick and dirty approximation and hope it's good enough.... ;Quote:Are you looking for constant volume?Constant volume would be an excellent result.  For example:Box [1m x 6m x 1m]-> Capsule [? Radius x ? Length]The longest box dimension would describe the length, then I could work out the volume from there?  What if 2 or more of the dimension are the same size?Orientation would assume T position pose for all shapes?   ;Quote:Box [1m x 6m x 1m]-> Capsule [? Radius x ? Length]There's the problem. You have to choose enough constraints for each conversion to solve the volume equation.E.g., volume of sphere = 4/3*pi*r3. For each "from" shape, pick the radius for the new sphere.Volume of capsule = 4/3*pi*r3 + pi*r2*cylinder_height. For each "from" shape, determine r and cylinder_height to be used.Etc.Given the volume of the "from" shape, you'll need equations for sphere radius in terms of volume. For capsule, you'll need to pick a radius (for instance) and an equation for length in terms of volume and radius.EDIT:For instance, converting to a sphere from some other shape:1. calculate volume of "from" shape.2. radius = ( volume/(4/3*pi) )-3That one's trivial. The other shapes are not going to be as simple.   ;  Would this be similar to containing each shape inside a bounding box?For example if I have a box 1x1x1, then I would make sure the other shapes fit inside that box.I'm guessing the easy way out of this would be to have a uniform scale factor for all shapes?  Changing between them would be trivial then.   ;Quote:Would this be similar to containing each shape inside a bounding box?No. There's no guarantee, because of the various shapes, that one volume shape would enlose another volume shape.Assuming reasonable (consistent) choices for choosing proportions, what it would mean (aside from possible small rounding errors) is that changing a shape to another and back again would result in the same size as the original, if that's important.Quote:For example if I have a box 1x1x1, then I would make sure the other shapes fit inside that box. I'm guessing the easy way out of this would be to have a uniform scale factor for all shapes? Changing between them would be trivial then.You can do that. Again, it depends on what you're really trying to accomplish. But, if you fit one shape inside another, then fit another shape inside that one, the result would be smaller and smaller objects.   ;  Well what I think I'm after is switching between shapes but keeping the dimensions similar:Sphere (Diameter 1m) -> Cube (1m x 1m x 1m) -> Cylinder (Diameter 1m x Height 1m) -> Cone (Diameter1 1m Diameter2 0m, Height 1m) etc.Does what I'm doing make sense?   ;Quote:Does what I'm doing make sense?Not really. Not without knowing what the exercise is about, Spa8nky.But if what you're trying satisfies you, that's what matters, no?   