plotting a shadow of an object in Matlab

22 次查看(过去 30 天)
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.

回答(1 个)

Harry MacDowel
Harry MacDowel 2011-7-4
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 个评论
Angelos
Angelos 2011-10-20
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by