Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8669243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:25:35+00:00 2026-06-12T18:25:35+00:00

I am trying to create a function using Matlab which takes the angle(specifies the

  • 0

I am trying to create a function using Matlab which takes the angle(specifies the rotation angle of the square) and the length of the square and returns a matrix containing 0 and 1 such that the value of each cell is 1 if and only if that cell be on the square, otherwise 0.

Following example helps to make it more clear:

d = 8 = length of square 
theta = 0
size of image containing the square = 16

img = zeros(16, 16);
img(o.x-d:o.x+d, o.y-d:o.y+d) = 1
output:
0000000000000000
0000000000000000
0000000000000000
0000000000000000
0000111111110000
0000111111110000
0000111111110000
0000111111110000
0000000000000000
0000000000000000
0000000000000000
0000000000000000

Example above is easy to show because the angle is equal to 0.
P.S. A way could be finding a position of each pixel(cell) and verify whether the pixel is inside the square or not, but the goal is finding a simple way.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:25:36+00:00Added an answer on June 12, 2026 at 6:25 pm

    The fastest way would probably involve a variation of Bresenham’s algorithm, but that won’t really make that much difference as compared to checking whether a particular pixel is inside the square or not. The latter is trivially done by rotating the pixel’s coordinates around the center and checking whether they are within the bounds, something like

    x' = (x - w/2)*cos(-alpha) - (y - h/2)*sin(-alpha)
    y' = (x - w/2)*sin(-alpha) + (y - h/2)*cos(-alpha)
    return abs(x') <= d/2 && abs(y') <= d/2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a popup for which I am using jQuery's CSS function.Here's
I am trying to create a function which takes a shell command as an
I'm trying to create a map of function names and function pointers using __stdcall.
I am trying to create a budget using a Match function, but I can't
I am trying to create a function which will give me alphabet position when
I'm trying to read a binary file (which represents a matrix in Matlab) in
I am using MySQL v5.1.36 and I am trying to create a stored function
I'm trying to create a function that returns frequency of IOS device's processor. The
I'm trying to create a boolean recursive function which accepts 1 parameter only and
I am trying to create a function guilabel_wrap(char *buffer, int maxlen) that takes a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.