LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-27-2016, 01:31 PM   #1
rico001
Member
 
Registered: Aug 2007
Distribution: TwisterOS lite, Linux in a VM
Posts: 77
Blog Entries: 3

Rep: Reputation: 3
Smile Circle square; How draw/compute w square pixels? Trigonometry, language


Greetings;

I have been out of high school and college for awhile. I struggled through math alot. I was wondering how a circle is drawn on the computer, and how a square is? I can't find the trigonomic equation for a square.

Was trying to look into programming languages to draw graphics on the screen. The Wolfram programming language looks intuitive. Also studying video and optics.

?Squaring the Circle :-)
Thanks.

Last edited by rico001; 04-27-2016 at 01:33 PM.
 
Old 04-27-2016, 01:41 PM   #2
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Location: Non. Je suis propriétaire – No. I am an owner.
Distribution: Apple-selling shops, markets and direct marketing: customers find the farm and buy apples.
Posts: 1,608
Blog Entries: 40

Rep: Reputation: 796Reputation: 796Reputation: 796Reputation: 796Reputation: 796Reputation: 796Reputation: 796
Good evening.

I regret to have mentioned this too often already, but I am not a native English speaker. Now, in your post, I read the words and understand what they say, but I still do not get what you are after...

Quote:
Originally Posted by rico001 View Post
I have been out of high school and college for awhile. I struggled through math alot. I was wondering how a circle is drawn on the computer, and how a square is? I can't find the trigonomic equation for a square.
PSE correct my understanding, where I am erring: Do you wish to program a routine that draws geometric forms on screen? Just like that or what would you hope to draw them on?
Alternatively, is it just the math that is missing and you are already happy with your chosen programming language and -environment?
Or.., are you wondering about how others do it?

Lastly, what kind of advantage would a “trigonometric equation“ for a square bring you, what would it facilitate? Maybe it is the wrong kind of question and just obstructs your way to drawing a plain ol' square.
 
Old 04-27-2016, 01:55 PM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
It will depend on the graphics library you're using. Most high level plotting libraries allow you to pass an array of X and Y coordinates, and the library will "connect the dots" so-to-speak. In that case, for a square you would simply pass it the coordinates of the corners, and in the process of connecting the dots, the library will draw your square for you. For a circle you would generate an array of angles from 0 to 2*pi, then your X and Y coordinates would be the cos() and sin() of those angles. The higher the resolution of your angles, the more "circular" your circle will be. Four points will draw a square, 8 will draw an octagon, and so on until it looks more and more round.
 
2 members found this post helpful.
Old 04-27-2016, 02:10 PM   #4
rico001
Member
 
Registered: Aug 2007
Distribution: TwisterOS lite, Linux in a VM
Posts: 77

Original Poster
Blog Entries: 3

Rep: Reputation: 3
Quote:
Originally Posted by Michael Uplawski View Post
Good evening.

...


PSE correct my understanding, where I am erring: Do you wish to program a routine that draws geometric forms on screen? Just like that or what would you hope to draw them on?
Alternatively, is it just the math that is missing and you are already happy with your chosen programming language and -environment?
Or.., are you wondering about how others do it?

Lastly, what kind of advantage would a “trigonometric equation“ for a square bring you, what would it facilitate? Maybe it is the wrong kind of question and just obstructs your way to drawing a plain ol' square.
you understood me well. suicidaleggroll, explained the square ok, but I do not understand the circle yet.

Last edited by rico001; 04-27-2016 at 02:11 PM.
 
Old 04-27-2016, 02:22 PM   #5
rico001
Member
 
Registered: Aug 2007
Distribution: TwisterOS lite, Linux in a VM
Posts: 77

Original Poster
Blog Entries: 3

Rep: Reputation: 3
Smile

Quote:
Originally Posted by suicidaleggroll View Post
It will depend on the graphics library you're using. Most high level plotting libraries allow you to pass an array of X and Y coordinates, and the library will "connect the dots" so-to-speak. In that case, for a square you would simply pass it the coordinates of the corners, and in the process of connecting the dots, the library will draw your square for you. For a circle you would generate an array of angles from 0 to 2*pi, then your X and Y coordinates would be the cos() and sin() of those angles. The higher the resolution of your angles, the more "circular" your circle will be. Four points will draw a square, 8 will draw an octagon, and so on until it looks more and more round.
The square makes sense and helps my learning, thanks. (from computer science I-II) 4 arrays, 2 for x and y, I get it, and I could say a hexidecimal rgb value for color. I don't like pi, (c/d) a example of some things I am looking at for fun... wxchaos on sourceforge I was also looking at puzzles such as: what's the smallest circle you could make. (64x64 pixels and still looks ok?) Thanks so far everyone, still confused about circles /'array of angles',I don't speak math, bad for me.

Last edited by rico001; 04-27-2016 at 02:28 PM. Reason: clarification,detail
 
Old 04-27-2016, 02:41 PM   #6
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,774

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
You can also use the (non-trigonomic?) circle equation: x^2 + y^2 = r^2, rearrange as a function of y = ±√(r^2 - x^2), no pi needed.
 
Old 04-27-2016, 04:48 PM   #7
rico001
Member
 
Registered: Aug 2007
Distribution: TwisterOS lite, Linux in a VM
Posts: 77

Original Poster
Blog Entries: 3

Rep: Reputation: 3
Smile

Quote:
Originally Posted by ntubski View Post
You can also use the (non-trigonomic?) circle equation: x^2 + y^2 = r^2, rearrange as a function of y = ±√(r^2 - x^2), no pi needed.
Thanks that explains and ends my confusion... When I typed in search trying to get the equation of circle, sites kept giving me square roots that I didn't want so that explains that. A site also mentioned Parametric Equation of a Circle is used to help with algorithms.

This answers many of my questions. Fractal Formula: z = tan(z) made a nice one. Will continue to research... Still have questions not directly related to topic, will mark as solved. Thanks everyone!

Last edited by rico001; 04-27-2016 at 04:59 PM. Reason: grammer error, salutations, rules -english format
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
square feet darksaurian General 3 01-10-2013 09:22 PM
[SOLVED] in Fedora 11 square screen have not adjust square of monitor. us_ed Linux - Hardware 27 10-05-2010 12:35 PM
gimp draw a simple square true_atlantis Linux - Software 4 03-30-2006 02:53 PM
square one - how do I make it go? linuxceptic Linux - Wireless Networking 3 02-04-2004 07:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration