LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   programm for perspective-grid (https://www.linuxquestions.org/questions/linux-newbie-8/programm-for-perspective-grid-918203/)

zenbo 12-16-2011 06:17 AM

Quote:

Originally Posted by Dark_Helmet (Post 4551228)
To draw a two-point perspective grid of a "floor" you could do this (with the revised script):
Code:

./grid -point 1 4.5 -radials 30 -anglestart 180 -point 10 4.5 -radials 30 -anglestart 180

ok mate, ill try it later, all grids have a horizont line where first and second vanishingpoints are put onto, the third point is above them.if you have time it would be nice if you could explain me the proper usage of the program,

see you later

Dark_Helmet 12-16-2011 11:43 AM

Quote:

Originally Posted by zenbo
ok mate, ill try it later, all grids have a horizont line where first and second vanishingpoints are put onto, the third point is above them.if you have time it would be nice if you could explain me the proper usage of the program

When you open your terminal to run the script, the revised script will print a length usage message if you run the script with no arguments (e.g. "./grid"). You'll need to scroll up in the terminal window to read it all.

Here's the high-level view of how the script works--what it's actually doing. Gnuplot is what draws the image. The script simply creates the data files that tell gnuplot what to draw.

Because gnuplot is more-or-less a tool designed to plot functions, the data files contain information in the form of coordinates and offsets. So, that is why the script requires vanishing points be given with coordinates. The script tries to simplify using coordinates by treating gnuplot's center-point/origin at the bottom left of the produced image. That way, the user will always be entering positive coordinates--no worrying about negatives (except for specific reasons). If you use the defaults, you can visualize this by drawing a graph-paper-grid on a sheet of paper (in landscape--i.e. longest dimension horizontal) with the grid lines 1 inch apart. That's the coordinate system.

When you specify a point to the script, you're giving the coordinate for a vanishing point. By default, a vanishing point is illustrated by drawing radial lines extending from the point you specify. If you take all the defaults, a radial will be drawn at 0 degrees (a horizontal line extending to the right) and additional radial lines will be drawn every 5 degrees counter-clockwise for a full rotation (i.e. all the way back to 0 degrees).

In a nutshell, that's it. That's all the script does. It calculates the coordinates needed for gnuplot to draw the radials. It gives you options to control how many radials are drawn, but it's all just a variation on the process above.

For two vanishing points to share a horizontal line: specify two points to the script with both points having the same y-coordinate (e.g. (1, 5) and (10, 5) --or-- (2, 7) and (7, 7))
Example command:
Code:

./grid -point 1 5 -point 10 5
That will draw two vanishing points with each having a radial drawn at 5 degree increments for the full 360 degrees. Both are on a horizontal line because their y-coordinates are the same value (5).

Example command:
Code:

./grid -point 1 5 -anglestart 180 -point 10 5
That will draw two vanishing points like the previous command. The difference is, the first vanishing point will NOT have any radials drawn above its horizon. This is caused by the "-anglestart" option. In this case, the starting angle for drawing radials for the first vanishing point is 180 degrees (which is a horizontal line extending to the left of the paper) and each additional radial will be drawn 5 degrees apart.

You can add as many points as you like:
Code:

./grid -point 1 3 -anglestart 180 -point 10 3 -anglestart 180 -point 5.5 7
Whether that produces the type of grid you want is up to you. You can play with the options. It's probably quicker for you to run an experiment with the script than waiting for me to see a question and respond.

Some "tricks":
To draw a horizontal line, include this as part of the script's options:
Code:

./grid -point 1 4 -radials 1
You interpret that as "draw one radial between 0 degrees and 360 degrees. The result is a radial drawn at 180. So, it draws a horizontal line 4 "inches" up from the bottom of the image.

To have a vanishing point have more radials at certain degrees. Try this:
Code:

./grid -point 4 4 -anglestop 45 -radials 50 -point 4 4 -anglestart 45 -anglestop 135 -radials 50 -point 4 4 -anglestart 135 -anglestop 180 -radials 50

Dark_Helmet 12-16-2011 01:17 PM

And, rather than add an edit to the previous post, here's a sample command that creates something sort of like the bottom half of the image from the original web page you linked to.

Code:

./grid -point 5.5 3.5 -radials 40 -anglestart 180 -point 0 3.25 -radials 1 -point 0 3 -radials 1 -point 0 2.5 -radials 1 -point 0 1.5 -radials 1
The first point-radials-anglestart sequence gives the radial lines. The following point-radials sequences define the horizontal lines: one point-radials sequence per horizontal line. The spacing of the horizontal lines is controlled by their respective y-coodinates. So, that command illustrates that you can get as complex or as simple as you like.

Something similar to the top half of the original image could be created by swapping things around. For instance:
Code:

./grid -point 5.5 5.5 -radials 40 -anglestop 180 -point 0 5.75 -radials 1 -point 0 6 -radials 1 -point 0 6.5 -radials 1 -point 0 7.5 -radials 1
You could also combine all those options in one really long command:
Code:

./grid -point 5.5 3.5 -radials 40 -anglestart 180 -point 0 3.25 -radials 1 -point 0 3 -radials 1 -point 0 2.5 -radials 1 -point 0 1.5 -radials 1 -point 5.5 5.5 -radials 40 -anglestop 180 -point 0 5.75 -radials 1 -point 0 6 -radials 1 -point 0 6.5 -radials 1 -point 0 7.5 -radials 1
Lastly, I should point out that gnuplot does support "true" 3D plot drawing. Though, I approached it from a straight 2D framework. Using gnuplot's 3D plotting abilities might give better results, but would require some significant re-working of the script to support. Or creating the necessary files for gnuplot by hand.

zenbo 12-16-2011 03:04 PM

dark helmet

i installed the script, it works fine, im trying all the options you includet, ill get back to you if i have more questions.
most of all i wanna say thank you for your effort, this was really cool of you, im having a buddy helping me, who is better on computers than me.

again thanks alot, ill let you know what i think of it. catch you later.

zenbo

Dark_Helmet 12-16-2011 03:26 PM

No problem. I hope it works for you.

Every so often I get a "programming itch." It just so happened that I had one right around the time you posted your original message and it dawned on me that the process could be automated (somewhat) with gnuplot.

So, as crazy as it might sound, I was entertained by the challenge of it. In addition to having entertained me, I hope it's ends up being useful for you :)

zenbo 12-16-2011 04:18 PM

Quote:

Originally Posted by Dark_Helmet (Post 4551948)
No problem. I hope it works for you.

Every so often I get a "programming itch." It just so happened that I had one right around the time you posted your original message and it dawned on me that the process could be automated (somewhat) with gnuplot.

So, as crazy as it might sound, I was entertained by the challenge of it. In addition to having entertained me, I hope it's ends up being useful for you :)

how come you can program so well, is it a job? are programing-languages for linux the same as say mac or windows?

Dark_Helmet 12-19-2011 11:04 PM

In all honesty, that script is not much of a programming feat, but I appreciate the compliment :)

As to your other questions, I've programmed here and there for a long time. Some in grade school, some in my university degree program, some professionally, and some just as a personal hobby. Though, I would not classify myself as a "professional" programmer. The work I did professionally was not the "software development" that most people think of.

And yes, programming languages are computer-independent. A computer language just specifies the "vocabulary and grammar" to use when programming. Any computer can then interpret that code as long as the computer has a compiler--a translator of sorts (keeping with the analogy).

If you ever decide to get into programming, you'll notice that there may be some cosmetic differences, but almost all programming languages support some core "features." Once you're proficient with one language, you probably won't need much time to become "competent" in another language.


All times are GMT -5. The time now is 06:07 AM.