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:
binary semicircle with angle

Subject: binary semicircle with angle

From: Steve

Date: 2 May, 2010 01:34:05

Message: 1 of 3

Hello!

Can someone please tell me how to draw a binary semicircle (not plotting!)? I can easily create a full circle:

c=3; s=5; r=2;
[x,y] = meshgrid(-(c-1):(s-c), -(c-1):(s-c));
circle = ((x.^2 + y.^2) <= r^2);

But how can I create a half circle with a specific angle? I tried imrotate on a semicircle, but thats not good and works slow. Any idea how to do that with indexing? Should be very fast.


Thank you!

Subject: binary semicircle with angle

From: Roger Stafford

Date: 2 May, 2010 02:36:05

Message: 2 of 3

"Steve " <stefan.griesser@alumni.unileoben.ac.at> wrote in message <hrikqd$srn$1@fred.mathworks.com>...
> Hello!
>
> Can someone please tell me how to draw a binary semicircle (not plotting!)? I can easily create a full circle:
>
> c=3; s=5; r=2;
> [x,y] = meshgrid(-(c-1):(s-c), -(c-1):(s-c));
> circle = ((x.^2 + y.^2) <= r^2);
>
> But how can I create a half circle with a specific angle? I tried imrotate on a semicircle, but thats not good and works slow. Any idea how to do that with indexing? Should be very fast.
>
>
> Thank you!

 circle = ((x.^2 + y.^2) <= r^2) & (y*cos(a)-x*sin(a)>=0);

where a is the angle made by the diameter of the semicircle with respect to the x-axis.

Roger Stafford

Subject: binary semicircle with angle

From: Steve

Date: 2 May, 2010 02:55:23

Message: 3 of 3

> circle = ((x.^2 + y.^2) <= r^2) & (y*cos(a)-x*sin(a)>=0);
>
> where a is the angle made by the diameter of the semicircle with respect to the x-axis.
>
> Roger Stafford


Thanks very much!

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