plotting a shadow of an object in Matlab

30 views (last 30 days)
TuCa
TuCa on 4 Jul 2011
Hi,
I have a project that requires me to use Matlab to plot a light source (which is a point), an 3D object (Rectangular Cuboid) with arbitrary position and orientation, and a shadow of the object on the XY plane. I am very new in the area of graphics. I have been searching for algorithms of generating a shadow of an object, but still don't know where to start. They seem to be too complicated to apply to my small project. I guess plotting a point, and 3D rectangular cuboid wouldn't be a problem, but the thing is how to create a mathematical model of the shadow and then plot it on XY plane. Could you please help me! Your help would be really appreciated.

Answers (1)

Harry MacDowel
Harry MacDowel on 4 Jul 2011
I don't think it's a very hard thing to do. Just draw a cone with the tip as the light source. Draw 4 lines connecting the light source (which I assume is a dot) to the 4 points (sometimes you will have more points) which encompasses the exterior top view of the rectangular cube then continue to extend the lines until it touches the XY plane.
Then you can calculate the surface area encompassed by the first four nearest points. Note the calculation of the area here since you are dealing with a rectangular cube. You can use the length of the line from the light source to each of the point to then calculate the planar area of the furthest point away from the light source. That will be the shape of the shadow down on XY plane.
After that, use simple scaling method to pinpoint the position of the 4 points down on the XY plane, and draw the 4 dots and connect them, then fill them with color. That's what I can think of when I hear your problem.
  1 Comment
Angelos
Angelos on 20 Oct 2011
I have been dealing with a similar problem and noticed this answer of yours.How do I extend a vector or line to the point of a given surface?Is there some Matlab function to simplify things?Any help would be appreciated.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!