Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: A little trigonometry  (Read 3101 times)

0 Members and 1 Guest are viewing this topic.

SavannahLion

  • Wiki Contributor
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5986
  • Last login:December 19, 2015, 02:28:15 am
A little trigonometry
« on: September 11, 2010, 08:56:22 pm »
For the life of me I can't figure this out. I just can't remember how it's done. :(

I know the answer is painfully obvious, but it's escaping my search-fu techniques.

And yes, it's arcade related, you'll see eventually.

In the example attachment below, I have a set of three overlapping triangles. Each coordinate is lettered A, B, C with a number indicating which belongs to which triangle. I have the ABC coordinates for ALL of the triangles (I should, I generated those numbers). I can figure out the angles and the lengths and whatever other information I need. What I can't figure out is intersections between the triangles. In the diagram below, it's the intersections outlined by the red circles.

Any trig majors here that can answer that question?

edit: Corrected diagram labeling.
« Last Edit: September 11, 2010, 09:15:40 pm by SavannahLion »

EvilNuff

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 430
  • Last login:February 24, 2024, 04:41:13 pm
Re: A little trigonometry
« Reply #1 on: September 11, 2010, 09:48:19 pm »
I don't really understand what you are asking...by "coordinate" do you mean x,y coords in a 2 dimensional space?  Are the letters locations or angles?  What do you want from the intersections, the x,y coord location or angles or what?

SavannahLion

  • Wiki Contributor
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5986
  • Last login:December 19, 2015, 02:28:15 am
Re: A little trigonometry
« Reply #2 on: September 11, 2010, 11:53:10 pm »
Oh shuckles. I'm a little rusty that. I've been using ABC interchangeably as x,y coordinates and angles.

To clarify in this case, the ABC values are created and stored as x,y coordinates. I'm trying to figure out the x,y coordinates of the red circled intersections.

SavannahLion

  • Wiki Contributor
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5986
  • Last login:December 19, 2015, 02:28:15 am
Re: A little trigonometry
« Reply #3 on: September 12, 2010, 12:23:36 am »
Oh  :censored: sky. I've been really over-complicating this. I've been treating the problem as whole triangles rather that intersecting lines.

For formula is y = m(x-Px) + Py where Px,Py is a known coordinate and m is the known slope. So for two lines and their intersect, the equation is simply m(x-Px) + Py = m(x-Px) + Py where the left of = is one line and the right is the other line. Solve for x then use x to solve for y.

Now I'm left to figure how to do this proagrammatically(?) without resorting to a math library.
« Last Edit: September 12, 2010, 12:32:48 am by SavannahLion »

jennifer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2895
  • Last login:August 11, 2023, 06:24:58 am
Re: A little trigonometry
« Reply #4 on: September 12, 2010, 10:55:29 pm »

  Arcade related you say..... I"ve studied it, and concluded, I"t doesn"t appear to be electrical in nature. [unless it"s a flux capacitor]
      If it"s a cab. build, well intense. Maybe, it would be easier to cut the trianges out and intersect them manualy.

Grasshopper

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2380
  • Last login:March 04, 2025, 07:13:36 pm
  • life, don't talk to me about life
Re: A little trigonometry
« Reply #5 on: September 24, 2010, 02:49:15 pm »
It's been a long time since I did anything like this, but from memory, one possible approach might be as follows:

If we assume a point on the line between points A and C is P1 then you can use the following formula to calculate P1:

P1 = A + n(C-A)

If we assume a point on the line between points C1 and C2 is P2 then you can use the following formula to calculate P2:

P2 = C1 + m(C2-C1)

At the intersection between the two lines P1 = P2 therefore:

A + n(C-A) = C1 + m(C2-C1)

Now split the above formula into two (one for the x values and one for the y values):

Ax + n(Cx-Ax) = C1x + m(C2x-C1x)

Ay + n(Cy-Ay) = C1y + m(C2y-C1y)

Now combine the above two formulae to calculate m:

m = [C1x - Ax - n(Cx-Ax) - C1y + Ay + n(Cy-Ay)]/[(C2y-C1y) - (C2x-C1x)]

Now we know m, we can calculate n.

I'd use a spreadsheet to do the calculation.
"Patriotism is the last refuge of the scoundrel." - Samuel Johnson

SavannahLion

  • Wiki Contributor
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5986
  • Last login:December 19, 2015, 02:28:15 am
Re: A little trigonometry
« Reply #6 on: September 26, 2010, 09:49:47 pm »

  Arcade related you say..... I"ve studied it, and concluded, I"t doesn"t appear to be electrical in nature. [unless it"s a flux capacitor]
      If it"s a cab. build, well intense. Maybe, it would be easier to cut the trianges out and intersect them manualy.

It's a software utility. The utility is written in C++ but I'm pre-generating parts of the GUI using Perl + ImageMagick. Originally had some wicked spaghetti code and resorted to Perl's version of OOP to handle the shape manipulation. I'm almost done with the prototype GUI but there's a hidden bug somewhere as the shapes approach virtual "0, 0" in the coordinates. Can't figure out what it is. :banghead:

I've discovered some disappointing information that abolished my assumptions about DirectX/OpenGL/GDI so I need to do more investigating into that.

In any case, I need to hammer out a couple of left over details and I can compile and release a -nogui version for peer review and debug at least the underlying functions.

To Grasshopper:

I've had one hell of a long weekend so I'm not really in the right mindset to digest your math equations there. If you haven't noticed, I'm rusty on math, I honestly have no clue who any of the presidents are on anything over $5, all I ever do nowadays is pure subtraction.  :cry:

Give me some lazy time at work and I'll digest your information.  :cheers:

KuraiDori

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 23
  • Last login:December 12, 2016, 10:36:55 pm
Re: A little trigonometry
« Reply #7 on: October 21, 2010, 04:34:18 pm »
What plane of hell did I stumble into?

SavannahLion

  • Wiki Contributor
  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5986
  • Last login:December 19, 2015, 02:28:15 am
Re: A little trigonometry
« Reply #8 on: October 23, 2010, 12:16:55 am »
What plane of hell did I stumble into?

Well... depends on your religion. If you believe in Dante's Hell, then it's probably the 8th circle, 10th ditch. Of course, if you ask the RIAA then it's the seventh ditch. I don't believe any of us really sunk that low. At worst, we're all probably either in the 2nd or 4th circle because most of us want, or have, too many cabs.

I'm almost done with the prototype GUI but there's a hidden bug somewhere as the shapes approach virtual "0, 0" in the coordinates. Can't figure out what it is. :banghead:

Not that any one cares, but the problem was the box coordinates changes as it approaches 0,0. I was calculating a virtual box with four corners but the coordinates as they arrive towards 0,0 changes into a three corner box (ie a triangle) but my program was expecting a true four corner box. A simple fix was to create a "virtual" corner to create my box for the calculations. Easy peasy. :)

KuraiDori

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 23
  • Last login:December 12, 2016, 10:36:55 pm
Re: A little trigonometry
« Reply #9 on: October 23, 2010, 12:12:33 pm »
That's quintessential

The solution as you explained it sounds very similar to the one that I postulated, with the exception of being presented in a coherent format based on sound mathematical formulas that succeeded in explaining and solving the unexpected variances.
« Last Edit: October 23, 2010, 05:54:06 pm by KuraiDori »