View Full Version : curve with straight lines
Cloud No.9
11-01-2005, 01:28 PM
does anyone know how you would draw a curve with straight lines? i know what it looks like. a set of increasing gradient lines from the horizontal and vertical planes. but i can't do it all using my way. can someone give me a step by step process or a link please?
bipper
11-01-2005, 04:27 PM
Cloud, your too smart. IS this what you are looking for? :LINKAGE (http://mathforum.org/library/drmath/view/56710.html)
Flying Mullet
11-01-2005, 04:32 PM
Cloud, you're too smart. IS this what you are looking for? :LINKAGE (http://mathforum.org/library/drmath/view/56710.html)
:smash:
Cloud No.9
11-01-2005, 05:03 PM
okay i worked it out. now my little program is complete.
Samuraid
11-01-2005, 05:15 PM
Program? Ah, so that's what you were taking about. I thought you wanted to draw it by hand or something along those lines. :rolleyes2
Cloud No.9
11-01-2005, 05:40 PM
yeah well i wanted to understand how it was done by hand first so i got the idea.
bipper
11-01-2005, 06:45 PM
:smash:
lol, yup your such a smart primate ;)
Ah cloud, why didn't you say it was a program, we had to do about the same in an intro to video game programming class. Actually, I think I have had to do it in 4 different classes, all with different languages..... redundant really :(
You'res truly,
Bipper
Cloud No.9
11-01-2005, 10:11 PM
i don't think many people code in ada/jewl.
Dr Unne
11-02-2005, 12:16 AM
#!/usr/bin/ruby
require 'gtk2'
require 'gnomecanvas2'
class CurveFromLines
def initialize(size=150)
Gtk.init()
@window = Gtk::Window.new()
@window.set_title("LinesFromCurve")
@window.set_default_size(size*2,size*2)
@window.signal_connect("delete_event") { Gtk::main_quit() }
@canvas = Gnome::Canvas.new()
@canvas.set_center_scroll_region(true)
@canvas.set_pixels_per_unit(0.8)
@root = @canvas.root
0.upto(size) do |x|
color = 65535 - (x * 65535 / size)
line = Gnome::CanvasLine.new(
@root,
{
:points => [[0,x], [size-x,0]],
:"fill-color-gdk" => Gdk::Color.new(color,color,color)
}
)
line2 = Gnome::CanvasLine.new(
@root,
{
:points => [[0,-x], [-size+x,0]],
:"fill-color-gdk" => Gdk::Color.new(color,color,color)
}
)
end
@vbox = Gtk::VBox.new()
@vbox.pack_start(@canvas)
@window.add(@vbox)
@window.show_all()
Gtk.main()
end
end
curve = CurveFromLines.new(250)
Yamaneko
11-02-2005, 12:37 AM
In the real world aren't all curves a set of increasing gradient lines?
No, in the real world, curves are approximated using infinitesimally small lines.
"Gradient lines" don't even exist - you're probably referring to infinitely small lines.
bipper
11-02-2005, 01:27 PM
Ada is just fine. No harder than any other language really.
And I like that Unne :)
Bipper
Cloud No.9
11-03-2005, 06:18 PM
unne did it silly. it was too long. and it don't look like ada to me.
bipper
11-04-2005, 12:23 AM
Who cares. ADA is next to worthless, and Unne created his for a Linux enviroment. Assuming you may have used a differet complier, which CAN support different features, regaurdless of what ADAvangalists claim :)
Sides, this programming language looks like a simple cross between basic and c/C++. It makes me sick. Seriously though, the language is quite primative, and can tend to be bulky. Nothing speacial or new in my eyes.
Bipper
Dr Unne
11-04-2005, 12:42 AM
unne did it silly. it was too long. and it don't look like ada to me.
Ah, too long. OK...
<pre style="font-size:8pt">perl -MTk -MTk::Canvas -e '$c=MainWindow->new->Canvas->pack;$c->createLine(0,$_,250-$_,0)for(0..250);MainLoop'</pre>
I agree ADA is next to worthless.
EDIT: Ruby is only like C on the surface. Ruby is pretty nice. The code I wrote looks like C because GTK is based on C and it's just using a Ruby wrapper over GTK. A Ruby-ish program written in Ruby looks quite different.
Old Manus
11-04-2005, 11:08 PM
</>
Powered by vBulletin® Version 4.2.3 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.