Trig + Triangles = program?

Discussion in 'OT Technology' started by Astro, Nov 15, 2003.

  1. Astro

    Astro Code Monkey

    Joined:
    Mar 18, 2000
    Messages:
    2,047
    Likes Received:
    0
    Location:
    Cleveland Ohio
    While sitting in my pre-calc class listening to the prof go over trig with triangles, I was thinking: it would be cool to have a triangle solver!

    Ideally it should:

    - Ask for ANY 3 pieces of the triangle (1 side and 2 angles, 3 angles, 3 sides, 1 angle and 2 sides, etc)
    - Calculate the other 3 missing pieces (the missing angles and sides) - found out you have to be careful. The triangle MAY have 2 solutions so you need to find 'em.
    - Area and perimeter since we're here but this is somewhat optional

    I've got a TI-89 and TI-85. This can be done so I'm going to give it a whirl (targetting the 89). I'd be curious if there's any mentally insane people out there who would find this an interesting project (technically, this could be done in any language although ones that support sin, cos, and tan would make it a bit easier).

    I'm going to go hack away. If anyone actually wants the finished program, let me know...
     
  2. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    Heh, maybe that'll be my project to help me learn Tcl/Tk. If I have time.
     
  3. Astro

    Astro Code Monkey

    Joined:
    Mar 18, 2000
    Messages:
    2,047
    Likes Received:
    0
    Location:
    Cleveland Ohio
    Hmm... Solving the sides when you know 3 angles doesn't make sense. You need at least 1 side to put things in perspective (I'm thinking out loud - correct me if I'm wrong).

    So far I've got it solving 3 sides. The 2 sides/angles are going to be a bit more challenging since I have only TI's BASIC tool set to work with (I don't know 68k Assembler and I have a feeling its going to make this app more challenging anyways).
     
  4. Zourn

    Zourn 16-bit Ninja OT Supporter

    Joined:
    Apr 3, 2002
    Messages:
    2,354
    Likes Received:
    0
    Location:
    Texas
    I used to have several programs that I wrote for my TI-83+. My favorite was the one that did Synthetic Division.
     
  5. OmniFire

    OmniFire *************************

    Joined:
    Oct 19, 2003
    Messages:
    3,778
    Likes Received:
    0
    Location:
    Austin
    YES!! I NEED SOMETHING LIKE THIS

    also the trig everything solver in terms of pi

    i hate precal with a passion
     
  6. silversilvia

    silversilvia OT Supporter

    Joined:
    Sep 28, 2003
    Messages:
    1,066
    Likes Received:
    0
    there is such programs. my friend made one (on the calculator, it was a ti 83) his wasn't perfect, but we later on dl'd a program that was.
     
  7. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    Come to think of it, I wrote a similar one on my TI-83 when I was in grade 10... It did various things including at least some of what you describe. Unfortunately, I didn't really care enough about it to buy a link cable and put it on my computer before I had to clear my calculator for a test, so that program is long gone.

    And, like OmniFire said, a program that solves in terms of pi (or even goes degrees -> radians in terms of pi) would be very very cool.
     
  8. Astro

    Astro Code Monkey

    Joined:
    Mar 18, 2000
    Messages:
    2,047
    Likes Received:
    0
    Location:
    Cleveland Ohio
    For the program you did in 10th grade, was it strictly for right triangles?

    The program I'm working on is for all triangles (so Pathagorean's theorom comes into play, but A^2+B^2=C^2 will not work)

    As for trig, radians/degrees, and pi, go out now and get the TI-89! The 89 has the pretty print and when in radians, will aumatically pop in pi where needed. Its sweet stuff. And then when you need the decimal form, you just toss decimal in there. Most TI's have degrees-to-radians-to-degrees converters (my 85 did at least). Look for the superscript "r" for radians and put the calculator in degree mode, then enter the number with the "r" after it and it will convert the radian value to degrees (to go the other way, put calc in radians, enter degrees and put the superscript "o" or degree symbol after it and press enter). Or you could write a program (or find a program) to do this.

    If you have a TI-89: GET THE OS UPGRADE! I updated the OS on mine and discovered it added an entire Trig menu to it (as you know TIs have sin, cos, tan and the inverse of these 3). Well, the upgrade has csc, sec, and cot as well as their inverses! Technically, you can live without, but having these has made my life a lot easier.

    As for my triangle program, I've got it doing triangles with 3 sides and triangles with 1 side and 2 angles. The 2 sides and 1 angle is going to be a little harder since this one can produce 2 different triangles.
     
  9. Astro

    Astro Code Monkey

    Joined:
    Mar 18, 2000
    Messages:
    2,047
    Likes Received:
    0
    Location:
    Cleveland Ohio
    For giggles in case folks haven't seen it, I do have a collection of my TI apps up:

    http://www.rsbauer.com/ti.php

    There's a few TI-89 things (really haven't had a huge need to write any since the 89 has so many tricks available to it). There's a LOT of 85 stuff (86s might be able to run these apps). I went looking in there earlier today and found I did have a triangle app in there. But its only for right triangles.
     
  10. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    It was just for right triangles. I'm working on one now in Tcl, which will start only doing right triangles and at some point do all triangles maybe.

    As for calculators, the 83 converts between degrees and radians. I don't have an 89, but I might get one next year, we'll see (don't really have use for everything it does, and for now I'm happy with the 83's features).
     
  11. Astro

    Astro Code Monkey

    Joined:
    Mar 18, 2000
    Messages:
    2,047
    Likes Received:
    0
    Location:
    Cleveland Ohio
    Yeah, I think most of the TI graphers can do the conversion so a program really isn't needed to do it.

    As for getting the TI-89, if your going into engineering or go in a field heavy in math (or plan on doing some calculus), I'd HIGHLY recommend the TI-89. Split screen (handy, although I don't use it all the time). "Pretty Print" which shows you the exact equation/answer instead of the decimal approximate (when in radian mode, it WILL show you pi as a symbol instead of producing a decimal answer). Lots and lots of nifty little features - it runs circles around my TI-85 (its BASIC language set isn't very rich, but MUCH better than the TI-85 and TI-81). Of course, you could always wait until you're about to get hardcore on the math classes and pick up the latest and greatest from TI.

    Right triangles are kind of easy (don't mean to dis your work :) ). If this triangle app of mine goes, I'll post the code and app here.
     
  12. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    I'm going into Comp Sci, so yeah, pretty heavy on the math. I probably will get an 89 next year, I've played around with them a little, I know they're a lot better than the 83. You can do split screen on the 83 actually, but I almost never use it. I should use it more these days though, since we're doing trig equations.

    Yeah, right triangles are pretty easy, but I'm mainly doing this to learn Tcl/Tk (since I'm embarking on a major project in it), and it's a really good exercise to get started. I've got the interface together now (Tk is nice for interfaces), just gotta get the actual code working. Then maybe I'll look at adding functionality for non-right triangles.
     
  13. Astro

    Astro Code Monkey

    Joined:
    Mar 18, 2000
    Messages:
    2,047
    Likes Received:
    0
    Location:
    Cleveland Ohio
    :)

    I think I got it...

    Solves the following triangle flavors: SSS, SAS, SAA, SSA, ASA

    And I think I got SSA to work properly to identify if the solution yields 1 triangle, 2 triangles (and solutions for both) or no triangles (actually, you get "undef" for the angles)

    And since a right triangle is a special case of the law of sines, it should solve any right triangle you give it.

    I'm not confident about the code correctly producing 2 triangle solutions, so before I post the app, I'm going to go do my homework and stress test it there. I might post some screen shots though...
     
  14. Astro

    Astro Code Monkey

    Joined:
    Mar 18, 2000
    Messages:
    2,047
    Likes Received:
    0
    Location:
    Cleveland Ohio
    The input screen: (Enter any of the 3 pieces in any order)
    [​IMG]

    An AAS triangle:
    [​IMG]

    Output looks like this: (shows only the missing parts)
    [​IMG]
     
  15. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    :cool: But your interface is nowhere near as pretty as mine:
    [​IMG]
     
  16. Astro

    Astro Code Monkey

    Joined:
    Mar 18, 2000
    Messages:
    2,047
    Likes Received:
    0
    Location:
    Cleveland Ohio
    Nice!

    Yeah, I'm only working with a 10Mhz processor with 384k RAM and a 160x100 pixel display. But it gets the job done.

    Ok, I haven't stress tested it fully, but here's the links:

    Plain ASCII (need TI-92p Mini Sans font)
    http://www.rsbauer.com/ti/tritriangle.txt

    TI ASCII
    http://www.rsbauer.com/ti/trisolve.TXT

    The actual TI-89 program (right click and save as)
    http://www.rsbauer.com/ti/trisolve.89p

    The code is a small mess. Its been a while since I've played with TI BASIC so it was hammered out in a rush without a lot of thought to code design. Initial boot up takes a little bit, but the calculation goes fast. Once the solution is given, press ENTER to solve another triangle or any key to exit. Oh, there's no error checking so if you do something silly like specify the same angle or side more than once, it will produce undesirable results or exit with an error.
     

Share This Page