ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to teach myself basic cairo programming but I have got stuck on arcs. The official cairo manual says:
Quote:
Angles are measured in radians. An angle of 0.0 is in the direction of the positive X axis (in user space). An angle of M_PI/2.0 radians (90 degrees) is in the direction of the positive Y axis (in user space). Angles increase in the direction from the positive X axis toward the positive Y axis. So with the default transformation matrix, angles increase in a clockwise direction.
This seems to me contradictory, both in itself and with my experiments. If (+)M_PI/2 is the positive Y-axis, then an arc from 0 (the positive X axis) to M_PI/2 should go anti-clockwise, i.e. above the X-axis. But it does in fact go clockwise underneath the X-axis. What am I missing?
I'm trying to teach myself basic cairo programming but I have got stuck on arcs. The official cairo manual says:
This seems to me contradictory, both in itself and with my experiments. If (+)M_PI/2 is the positive Y-axis, then an arc from 0 (the positive X axis) to M_PI/2 should go anti-clockwise, i.e. above the X-axis. But it does in fact go clockwise underneath the X-axis. What am I missing?
I am not sure, Hazel, but the direction of the Y-axis may be downwards.
Taking "positive X axis" = east/right and "positive Y axis" = south/down you get...
Quote:
Angles are measured in radians. An angle of 0.0 is [east]. An angle of M_PI/2.0 radians (90 degrees) is [south]. Angles increase in the direction from the [east] toward the [south]. So with the default transformation matrix, angles increase in a clockwise direction.
Yes, but why on earth should the "positive" Y-axis be defined as the one that points downwards? The origin represents Y=0, and the Y-values plotted on the axis that points downward are negative. Positive values are on the upward-pointing Y-axis.
@astrogeek: Oh, I get a glimmer now after rereading your post. It's because of the longstanding convention about screen (and window) coordinates starting at the top left-hand corner, where down and right are the only available directions. But the cairo people really should have stated this explicitly as a parallel since it's far from obvious to the naive reader and their explanation makes no sense without it. Or do the words "(in user space)" do precisely that for those familiar with the terminology? (see appendix below)
@teckk I shall copy your program and examine it at leisure.
Appendix: So I googled "user space" and got some Java stuff like:
Quote:
Originally Posted by O'Reilly, Java Media APIs
User space is the coordinate space in which the user operates. At instantiation, the origin of user space is at the top-left corner of the screen with the x coordinate increasing to the right and the y coordinate increasing downward.
Last edited by hazel; 03-15-2024 at 01:53 AM.
Reason: Added appendix
Yes, but why on earth should the "positive" Y-axis be defined as the one that points downwards? The origin represents Y=0, and the Y-values plotted on the axis that points downward are negative. Positive values are on the upward-pointing Y-axis.
Writing Web-Applications in Europe, we oftentimes had to wonder how on earth Sunday can be considered the first day of the week. In the end, you seal your brain and adapt.
Mine is 3.24.31. So I made the change and now gcc works OK but then ld spits out some undefined symbol in libm.
Code:
/usr/bin/ld: /tmp/ccpTOwHV.o: undefined reference to symbol 'sin@@GLIBC_2.2.5'
/usr/bin/ld: /lib64/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Never mind. I can still study the source, which I assume was the point of your post.
That is absolutely amazing! Thank you Teckk and NevemTeve too. I'll add the program to my fluxbox startup file so that I can use it as active wallpaper. But I also intend to study the code; I'm sure there's a lot that I can learn from it.
Just for interest, here is my version of a tenor clef, completed today based on what I learned from this thread.
Yes, but why on earth should the "positive" Y-axis be defined as the one that points downwards?
Historical reasons. But think about a regular book, the first line is at the top, and the Y axis (line numbers) are counted from top to bottom. In a text editor the characters are counted from top left corner. It is exactly the same.
Thank you, Teckk. I didn't know about that site. This particular symbol btw can be used either as an alto or a tenor clef depending how high it is on the stave, hence the name.
In case anyone is wondering why I want to draw clefs, it is part of a program I wrote years ago as a personal front end to Philip's Music Writer (pmw), which is a brilliantly simple way of producing script music using a text code. pmwScribe gives you a screen stave on which you can pin notes and other musical glyphs and it translates them into pmw code. I wrote it using gtk2/gdk2 and I'm now trying to convert it into gtk3/cairo.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.