Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I want to draw a Cuboid accroding to the coordinates of its geometric center and its dimensions, rather than its diagnoal coordiantes. And How can I draw a triangular prism?

share|improve this question

marked as duplicate by whuber, Oleksandr R., Artes, J. M. Apr 8 '13 at 17:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Possible duplicate, or at least strongly related: – Mr.Wizard Apr 8 '13 at 4:01
Dear @user5463: you asked eleven questions and voted only twice. Is there something wrong with the answers you're getting in the site? Also, please change your userid for something more "human" :) – Dr. belisarius Apr 8 '13 at 4:35
Sorry about that, I did't realise that I had to vote that much. I voted for questions asked by others, does it have anything to do with my answers? – novice Apr 8 '13 at 5:53
up vote 5 down vote accepted
cuboid[center_, dim_ ] := Cuboid[center - dim/2, center + dim/2]

Graphics3D[cuboid[{6, 7, 8}, {1, 2, 3}], Axes -> True]

enter image description here

For the triangular prism see my answer here.


Please note that (by design)

cuboid[{c, c, c}, {xd, yd, zd}] == cuboid[ c, {xd, yd, zd}] 


cuboid[{cx, cy, cz}, {d, d, d}] == cuboid[ {cx, cy, cz}, d]

If you want

cuboid[ 1, 3 ]

to represent a cube of size 3 centered at {1, 1, 1}, you can modify the definition as follows:

cuboid[center_, dim_ ] := Cuboid[center - dim/2 + {0,0,0}, center + dim/2 + {0,0,0}]
share|improve this answer
belisarius Thanks,Big favor! – novice Apr 8 '13 at 7:04
center + dim/2 + {0, 0, 0} ?? – andandandand Apr 14 at 17:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.