CEMETECH
Leading The Way To The Future
Login [Register]
Username:
Password:
Autologin:

Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 124 users online: 7 members, 79 guests and 38 bots.
Members: geekboy1011, GISdude, JamesV.
Bots: VoilaBot (4), Spinn3r (1), MSN/Bing (1), Magpie Crawler (3), VoilaBot (11), Googlebot (1), Googlebot (16), MSN/Bing (1).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
Author Message
Devreugkx


Newbie


Joined: 21 Feb 2012
Posts: 18
Location: The Netherlands

Posted: 11 May 2012 10:10:21 am    Post subject: Buffon's Needle

Hi,

I was trying to make a simulation of Buffon's Needle on the TI-84+.
But I couldn't make it.
Maybe someone else can?

What's Buffon's Needle?
http://en.wikipedia.org/wiki/Buffon%27s_needle
http://mste.illinois.edu/reese/buffon/bufjava.html
Back to top
merthsoft


File Archiver


Joined: 09 May 2010
Posts: 2735

Posted: 11 May 2012 10:12:39 am    Post subject:

Why did you give up? Did you come across a problem you couldn't get past? Why not try to make it and ask here if there's something hanging you up.
_________________
Shaun
Back to top
Aes_Sedia5


Minor Calculator Deity


Joined: 01 Sep 2011
Posts: 1002
Location: Where Nightmares end and Dreams begin

Posted: 11 May 2012 10:46:37 am    Post subject:

We have many people here that can help. I have found in most situations, it is one or two small things that you are missing.
_________________




Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55746
Location: Earth, Sol, Milky Way

Posted: 11 May 2012 11:53:11 am    Post subject:

I second what both of these two said. Since you're posting in the TI-BASIC help forum, it would seem appropriate for us to help you through whatever is making you be stuck. Are you having trouble imagining the overall structure of the program in TI-BASIC, or some specific technical detail?
_________________


Back to top
Devreugkx


Newbie


Joined: 21 Feb 2012
Posts: 18
Location: The Netherlands

Posted: 11 May 2012 02:22:20 pm    Post subject:

I aspecially have a program with how I should program how the needle should fall.

I thought about random generate an X and Y starting coordinate and than an X an Y end coort. But than the line could be any length.
So I thought about also generate a number between 0 and 360 and draw a line (=the needle) from begin point in the generated direction.
But I have no idea how I should make that AND let the length be always the same length.

To check if the needle crosses one of the lines, I thought I could use the Pixel/Point check command. But don't know how to configure that one, because I never used it.

That are myt problems so far.
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55746
Location: Earth, Sol, Milky Way

Posted: 11 May 2012 02:40:17 pm    Post subject:

Well, if you have a starting point (x1,y1), a length n (I chose n instead of l because l looks like 1 in monospaced font), and an angle Θ, then the math works like this:


Code:
Starting point = (x1,y1)
Length= n
Angle = Θ
Ending point = (x2, y2)
x2 = x1 + ncos(Θ)
y2 = y1 + nsin(Θ)
Thus ending point = (x1+ncos(Θ), x2 + nsin(Θ))


That will always give you a line of length n.
_________________


Back to top
Kaslai


Member


Joined: 16 Nov 2011
Posts: 172
Location: ???, WA

Posted: 11 May 2012 06:16:08 pm    Post subject:

Remember, when dealing with trig functions, pay attention as to if the calculator is in degrees or radians.

As far as detecting an intersection, this can be found by determining which strip either point is in and comparing.
given W = width of the strips and X1, Y1, X2, and Y2 are the relevant coordinates of the points, an intersection can be found with the inequality

Code:
iPart( X2 / W) =/= iPart( X1 / W )

(Use Y1 and Y2 if the strips are horizontal instead of vertical)
_________________



Back to top
Devreugkx


Newbie


Joined: 21 Feb 2012
Posts: 18
Location: The Netherlands

Posted: 13 May 2012 10:00:55 am    Post subject:

@KermM, the code works, thanks!

@Kaslai, the iPart function is really helpful, but sometimes it gives a 'false' signal...
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55746
Location: Earth, Sol, Milky Way

Posted: 13 May 2012 11:49:00 am    Post subject:

What do you mean by that? Did you write the two cases, for horizontal and vertical strips, as Kaslai said? Or just the one?
_________________


Back to top
Devreugkx


Newbie


Joined: 21 Feb 2012
Posts: 18
Location: The Netherlands

Posted: 13 May 2012 11:56:30 am    Post subject:

I made a little mistake while programming, it's works fine now!
After about 500 needles, Pi was 3,18.
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55746
Location: Earth, Sol, Milky Way

Posted: 14 May 2012 09:35:40 am    Post subject:

Devreugkx wrote:
I made a little mistake while programming, it's works fine now!
After about 500 needles, Pi was 3,18.
Superb! Are you going to shine this up a bit and upload it to our program archives? Smile
_________________


Back to top
Devreugkx


Newbie


Joined: 21 Feb 2012
Posts: 18
Location: The Netherlands

Posted: 14 May 2012 11:02:12 am    Post subject:

I will! Very Happy
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are GMT - 5 Hours

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.034426 seconds.