plotting a shadow of an object in Matlab

조회 수: 17 (최근 30일)
TuCa
TuCa 2011년 7월 4일
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