Skip to content

Instantly share code, notes, and snippets.

@atomicules
Created March 22, 2010 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atomicules/339896 to your computer and use it in GitHub Desktop.
Save atomicules/339896 to your computer and use it in GitHub Desktop.
#For answering question on Shoes mailing list dmonroe
Shoes.app(:title => "Coplanar Points", :width => 550, :height => 400) do
def calculate
@beex = (@betax.text.to_f-@alphax.text.to_f)
@beey = (@betay.text.to_f-@alphay.text.to_f)
@beez = (@betaz.text.to_f-@alphaz.text.to_f)
@ceex = (@gammax.text.to_f-@alphax.text.to_f)
@ceey = (@gammay.text.to_f-@alphay.text.to_f)
@ceez = (@gammaz.text.to_f-@alphaz.text.to_f)
@deex = (@deltax.text.to_f-@alphax.text.to_f)
@deey = (@deltax.text.to_f-@alphay.text.to_f)
@deez = (@deltax.text.to_f-@alphaz.text.to_f)
((@beex*((@ceey*@deez)-(@ceez*@deey)))-(@beey*((@ceex*@deez)-(@ceez*@deex)))+(@beez*((@ceex*@deey))-(@ceey*@deex)))
end
stack(:width => '100%', :margin => 20) do
para('Calculate Coplanar Points')
para(' x y z')
end
flow(:width => '100%' ) do
para('Point A: ')
@alphax = edit_line(:width => 100, height => 35) {@coplanar.text = calculate}
@alphay = edit_line(:width => 100, height => 35) {@coplanar.text = calculate}
@alphaz = edit_line(:width => 100, height => 35) {@coplanar.text = calculate}
end
flow(:width => '100%' ) do
para('Point B: ')
@betax = edit_line(:width => 100, height => 35) {@coplanar.text = calculate}
@betay = edit_line(:width => 100, height => 35) {@coplanar.text = calculate}
@betaz = edit_line(:width => 100, height => 35) {@coplanar.text = calculate}
end
flow(:width => '100%' ) do
para('Point C: ')
@gammax = edit_line(:width => 100, height => 35) {@coplanar.text = calculate}
@gammay = edit_line(:width => 100, height => 35) {@coplanar.text = calculate}
@gammaz = edit_line(:width => 100, height => 35) {@coplanar.text = calculate}
end
flow(:width => '100%' ) do
para('Point D: ')
@deltax = edit_line(:width => 100, height => 35) {@coplanar.text = calculate}
@deltay = edit_line(:width => 100, height => 35) {@coplanar.text = calculate}
@deltaz = edit_line(:width => 100, height => 35) {@coplanar.text = calculate}
@button = button "Configure" do
c = calculate==0
case c
when true
alert("Points are coplanar, equation is")
when false
alert("Points are NOT coplanar")
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment