MATLAB Newsgroup

I have a code that allows the user to specify the position of a light

source and an ellipse-shaped obstruction. To keep this post concise,

I've omitted details about how all the equations are solved and merely

put in the results that lead to the IF loop; To summate, the code

specifies the angular extent between the light at XY and the tangent

points of the ellipse, and all points outside this angular extent are

illuminated (This is shown in figure 2 in the code).

To compute the irradiances INSIDE the angular extent (while all points

in and beyond the ellipse are not illuminated, the points before the

ellipse are and this makes the question tricky) the code finds a

circumcentre to the tangent points and XY, and the angular extent of

these points. It then works out the radius of this circumcircle. It

draws a modified arc between the tangent points, with the

circumcentre as the centre and the arc modified to with a cosine

condition to be a straightline (shown in Figure 3 in the code)

These conditions are combined in Figure I, but as you can see, the

most right tangent line is no longer in agreement with the beta

condition..in fact, light "bends" around the ellipse at one point and

I wish to eradicate this error. Can anyone help? I know this is messy

coding but I really need an answer soon. Thanks in advance, David.

---------------------------------------------------------------------------------------

format long

Irad=zeros([1000 1000]);

warning off all

clear

H = 1.75;

P = 100;

gsize=100;

a = .15; %condition for ellipse

b = .05; %condition for ellipse

h = .5; %condition for ellipse

k = .5; %condition for ellipse

A = P/(2*pi*H); %Power rule

X = 0.1; %position of tube X co-ord

Y = 0.1; %position of tube Y-co-ord

%Circumcentre of two Tangent points and tube point

w = 0.45750000000000

v = 0.16250000000000

%Radius of circle

Rcirc = 0.36292216796443;

%Lambda, the relative angle between the circumcentre and tangent

points

cosinelambda = 0.92007972078891;

lambda = 0.40251238126841;

%Gamma, the angle between XY and the bisector of the tangent line

gamma = 0.81660756839543;

%The angle beta, between XY and the tangent points

beta = 0.20125619063420;

%The real angle between the midpoint of the tangent lines and

circumcentre

gammae = 1.46013910562100;

%Loop 1

for n = 1:1000

for m = 1:1000

rp = sqrt( ((n/1000)-(X)).^2 + ((m/1000)-(Y)).^2 ); % distance from

XY to any point

D = sqrt( ((n/1000)-(w)).^2 + ((m/1000)-(v)).^2 ); % distance from wv

to any point circumcentre

eq = (a^-2)*((n/1000)^2) - (a^-2)*(2*h*(n/1000)) + (b^-2)*((m/1000)^2)

- (b^-2)*(2*k*(m/1000)) + ((a^-2)*(h^2) + (b^-2)*(k^2) - 1);

ang = atan2(((m/1000) - Y),((n/1000) - X)); %angle between XY and

point

delta = atan2(((m/1000) - v),((n/1000) - w)); % angle between WV and

point

delta_eff = abs(gammae - atan2(((m/1000) - v),((n/1000) - w))); %

angle between WV and point relative lambda

cosdel = abs(cos(delta_eff));

ratio = cosinelambda / cosdel;

R_e = Rcirc*ratio;

if abs(mod(gamma -ang +pi,2*pi)-pi) < beta && (abs(mod(gammae -delta

+pi,2*pi)-pi) < lambda && D > R_e) || eq <= 0

I = 0;

else

I = A ./ rp;

end

Irad(n,m) = sum(I);

end

end

[XM,YM]=meshgrid(0.1:0.1:gsize , 0.1:0.1:gsize);

figure(1)

pcolor(YM,XM,log(Irad)), title('Log of Intensity versus distance

graph')

xlabel('Centimetres'), ylabel('Centimetres')

shading interp

%Loop 2 Demonstrating the beta confines

for n = 1:1000

for m = 1:1000

rp = sqrt( ((n/1000)-(X)).^2 + ((m/1000)-(Y)).^2 ); % distance from

XY to any point

D = sqrt( ((n/1000)-(w)).^2 + ((m/1000)-(v)).^2 ); % distance from wv

to any point circumcentre

eq = (a^-2)*((n/1000)^2) - (a^-2)*(2*h*(n/1000)) + (b^-2)*((m/1000)^2)

- (b^-2)*(2*k*(m/1000)) + ((a^-2)*(h^2) + (b^-2)*(k^2) - 1);

ang = atan2(((m/1000) - Y),((n/1000) - X)); %angle between XY and

point

delta = atan2(((m/1000) - v),((n/1000) - w)); % angle between WV and

point

cosdel = abs(cos(atan2((m/1000) - v,(n/1000) - w)));

cosdel2 = abs(cos(delta));

R_e = Rcirc*(cosinelambda/cosdel2);

if abs(mod(gamma -ang +pi,2*pi)-pi) < beta

I = 0;

else

I = A ./ rp;

end

Irad2(n,m) = sum(I);

end

end

[XM,YM]=meshgrid(0.1:0.1:gsize , 0.1:0.1:gsize);

figure(2)

pcolor(YM,XM,log(Irad2)), title('Log of Intensity versus distance

graph')

xlabel('Centimetres'), ylabel('Centimetres')

shading interp

%Loop 3 The extent of lambda

for n = 1:1000

for m = 1:1000

rp = sqrt( ((n/1000)-(X)).^2 + ((m/1000)-(Y)).^2 ); % distance from

XY to any point

D = sqrt( ((n/1000)-(w)).^2 + ((m/1000)-(v)).^2 ); % distance from wv

to any point circumcentre

eq = (a^-2)*((n/1000)^2) - (a^-2)*(2*h*(n/1000)) + (b^-2)*((m/1000)^2)

- (b^-2)*(2*k*(m/1000)) + ((a^-2)*(h^2) + (b^-2)*(k^2) - 1);

ang = atan2(((m/1000) - Y),((n/1000) - X)); %angle between XY and

point

delta = atan2(((m/1000) - v),((n/1000) - w)); % angle between WV and

point

delta_eff = abs(gammae - atan2(((m/1000) - v),((n/1000) - w))); %

angle between WV and point relative lambda

cosdel = abs(cos(delta_eff));

ratio = cosinelambda / cosdel;

R_e = Rcirc*ratio;

if abs(mod(gammae -delta +pi,2*pi)-pi) < lambda && D > R_e

I = 0;

else

I = A ./ rp;

end

Irad3(n,m) = sum(I);

end

end

[XM,YM]=meshgrid(0.1:0.1:gsize , 0.1:0.1:gsize);

figure(3)

pcolor(YM,XM,log(Irad3)), title('Log of Intensity versus distance

graph')

xlabel('Centimetres'), ylabel('Centimetres')

shading interp

DRG <grimesd2@gmail.com> wrote in message <180148c8-dd7d-42c5-bf61-de2c945a05fd@g3g2000pre.googlegroups.com>...

> I have a code that allows the user to specify the position of a light

> source and an ellipse-shaped obstruction. To keep this post concise,

> I've omitted details about how all the equations are solved and merely

> put in the results that lead to the IF loop; To summate, the code

> specifies the angular extent between the light at XY and the tangent

> points of the ellipse, and all points outside this angular extent are

> illuminated (This is shown in figure 2 in the code).

>

> To compute the irradiances INSIDE the angular extent (while all points

> in and beyond the ellipse are not illuminated, the points before the

> ellipse are and this makes the question tricky) the code finds a

> circumcentre to the tangent points and XY, and the angular extent of

> these points. It then works out the radius of this circumcircle. It

> draws a modified arc between the tangent points, with the

> circumcentre as the centre and the arc modified to with a cosine

> condition to be a straightline (shown in Figure 3 in the code)

>

> These conditions are combined in Figure I, but as you can see, the

> most right tangent line is no longer in agreement with the beta

> condition..in fact, light "bends" around the ellipse at one point and

> I wish to eradicate this error. Can anyone help? I know this is messy

> coding but I really need an answer soon. Thanks in advance, David.

> ........

DRG, I don't have time to struggle through your code. However, I question the necessity of dealing with the circumscribed circle through the points of tangency and XY. It seems to me that once you have calculated the two tangent points, all you need do is determine the equation of the line through them. Then an arbitrary point (x,y) is illuminated if either 1) it lies outside your "angular extent" or 2) it lies inside, also lies outside the ellipse, and in addition lies on the same side of the above line as the light source XY does. These are all simple calculations which ought to require much less code than I see here.

Roger Stafford

You can think of your watch list as threads that you have bookmarked.

You can add tags, authors, threads, and even search results to your watch list. This way you can easily keep track of topics that you're interested in. To view your watch list, click on the "My Newsreader" link.

To add items to your watch list, click the "add to watch list" link at the bottom of any page.

To add search criteria to your watch list, search for the desired term in the search box. Click on the "Add this search to my watch list" link on the search results page.

You can also add a tag to your watch list by searching for the tag with the directive "tag:tag_name" where tag_name is the name of the tag you would like to watch.

To add an author to your watch list, go to the author's profile page and click on the "Add this author to my watch list" link at the top of the page. You can also add an author to your watch list by going to a thread that the author has posted to and clicking on the "Add this author to my watch list" link. You will be notified whenever the author makes a post.

To add a thread to your watch list, go to the thread page and click the "Add this thread to my watch list" link at the top of the page.

*No tags are associated with this thread.*

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.

Got questions?

Get answers.

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

Learn moreDiscover what MATLAB ^{®} can do for your career.

Opportunities for recent engineering grads.

Apply TodayThe newsgroups are a worldwide forum that is open to everyone. Newsgroups are used to discuss a huge range of topics, make announcements, and trade files.

Discussions are threaded, or grouped in a way that allows you to read a posted message and all of its replies in chronological order. This makes it easy to follow the thread of the conversation, and to see what’s already been said before you post your own reply or make a new posting.

Newsgroup content is distributed by servers hosted by various organizations on the Internet. Messages are exchanged and managed using open-standard protocols. No single entity “owns” the newsgroups.

There are thousands of newsgroups, each addressing a single topic or area of interest. The MATLAB Central Newsreader posts and displays messages in the comp.soft-sys.matlab newsgroup.

**MATLAB Central**

You can use the integrated newsreader at the MATLAB Central website to read and post messages in this newsgroup. MATLAB Central is hosted by MathWorks.

Messages posted through the MATLAB Central Newsreader are seen by everyone using the newsgroups, regardless of how they access the newsgroups. There are several advantages to using MATLAB Central.

**One Account**

Your MATLAB Central account is tied to your MathWorks Account for easy access.

**Use the Email Address of Your Choice**

The MATLAB Central Newsreader allows you to define an alternative email address as your posting address, avoiding clutter in your primary mailbox and reducing spam.

**Spam Control**

Most newsgroup spam is filtered out by the MATLAB Central Newsreader.

**Tagging**

Messages can be tagged with a relevant label by any signed-in user. Tags can be used as keywords to find particular files of interest, or as a way to categorize your bookmarked postings. You may choose to allow others to view your tags, and you can view or search others’ tags as well as those of the community at large. Tagging provides a way to see both the big trends and the smaller, more obscure ideas and applications.

**Watch lists**

Setting up watch lists allows you to be notified of updates made to postings selected by author, thread, or any search variable. Your watch list notifications can be sent by email (daily digest or immediate), displayed in My Newsreader, or sent via RSS feed.

- Use a newsreader through your school, employer, or internet service provider
- Pay for newsgroup access from a commercial provider
- Use Google Groups
- Mathforum.org provides a newsreader with access to the comp.soft sys.matlab newsgroup
- Run your own server. For typical instructions, see: http://www.slyck.com/ng.php?page=2