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?
Asked
Active
Viewed 1,300 times
0
-
Possible duplicate, or at least strongly related: http://mathematica.stackexchange.com/q/10572/121 – Mr.Wizard Apr 08 '13 at 04:01
-
1Dear @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 08 '13 at 04: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 08 '13 at 05:53
1 Answers
5
cuboid[center_, dim_ ] := Cuboid[center - dim/2, center + dim/2]
Graphics3D[cuboid[{6, 7, 8}, {1, 2, 3}], Axes -> True]

For the triangular prism see my answer here.
Edit
Please note that (by design)
cuboid[{c, c, c}, {xd, yd, zd}] == cuboid[ c, {xd, yd, zd}]
and
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}]
Dr. belisarius
- 115,881
- 13
- 203
- 453