Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Lighting help!

Subject: Lighting help!

From: Husam Aldahiyat

Date: 16 Aug, 2009 07:26:02

Message: 1 of 4

Hello,

I have a 2D patch (rectangle). I want to create a line of light that horizontally crosses it in the middle.

How can I do this!? I tried playing with the position property of light() but it's not working :(

Subject: Lighting help!

From: Husam Aldahiyat

Date: 16 Aug, 2009 08:05:20

Message: 2 of 4

I did something but it's half-baked. Any suggestions?

a = [ 0 0 0
0.75 0 0
0.75 0.2 0
0 0.2 0
0 0 0.15
0.75 0 0.15
0.75 0.2 0.15
0 0.2 0.15].*10;

b=[1 2 6 5;2 3 7 6;3 4 8 7;4 1 5 8;1 2 3 4;5 6 7 8];

lp=patch('vertices',a,'faces',b,'edgecolor','k','facecolor',[.24 .24 .24]+.1,'linewidth',2);

hold on

for k=-.5:.1/2:.5

r = [.75/2+k .1 .195].*10;
light('Position',r,'style','local')

end
axis([-1 1 -1 1 -.5 .5].*10)

lighting phong

Subject: Lighting help!

From: Husam Aldahiyat

Date: 16 Aug, 2009 10:04:02

Message: 3 of 4

I'll rephrase my question.

I need to create one ray of light to cross a rectangular object.

Subject: Lighting help!

From: Husam Aldahiyat

Date: 18 Aug, 2009 06:25:20

Message: 4 of 4

Here is my newest effort.

close gcf
[X,Y,Z] = cylinder([5,5],140);
s = surf(X,Y,Z.*1);

shading interp

axis off

set(gcf,'color','w')
rotate(s,[1,0,0],90)
rotate(s,[0,1,0],90)

a=zeros(255,3);
a(:,2)=transpose(linspace(.5,.7,255));

colormap(a);

r = [7,-.5,1];

light('position',r,'style','loc')

r = [7,.5,1];

light('position',r,'style','loc')

rotate3d

view(90,0)
axis square

Anything better?

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us