plotting a shadow of an object in Matlab

17 visualizzazioni (ultimi 30 giorni)
TuCa
TuCa il 4 Lug 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.

Risposte (1)

Harry MacDowel
Harry MacDowel il 4 Lug 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 Commento
Angelos
Angelos il 20 Ott 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.

Accedi per commentare.

Categorie

Scopri di più su Lighting, Transparency, and Shading in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by