Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  figureing out the x,y, and z rotation of a right triangle?  (Read 1579 times)
0 Members and 1 Guest are viewing this topic.
Offline CyanPrime
« Posted 2010-12-06 21:54:34 »

I have a triangle made of 3 vertices. I need to know what the angle of the triangle is.

How would I go about it?
Offline pjt33
« Reply #1 - Posted 2010-12-06 22:41:42 »

Cos rule. a^2 = b^2 + c^2 - 2 b c cos A

Edit: although if you're talking about a situation where numerical analysis matters then read http://www.cs.berkeley.edu/~wkahan/Triangle.pdf
Offline SimonH
« Reply #2 - Posted 2010-12-06 22:44:47 »

or the dot product would do it.

People make games and games make people
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CyanPrime
« Reply #3 - Posted 2010-12-07 04:09:56 »

My bad. It's 2 points, not a triangle  persecutioncomplex

Alright, so I got two vectors that each contain a x y and z. We'll call them a and b.

I create a new point in the middle of the two points.

Vector3 middle = new Vector3(//order x,y,z
        (max.getX() - min.getX())/2,
        (max.getY() - min.getY())/2,
        (max.getZ() - min.getZ())/2
        );

To get the y angle I use the formula Math.toDegrees(Math.atan2(middle.getX(), middle.getZ()))
Offline pjt33
« Reply #4 - Posted 2010-12-07 10:57:44 »

I create a new point in the middle of the two points.

Vector3 middle = new Vector3(//order x,y,z
        (max.getX() - min.getX())/2,
        (max.getY() - min.getY())/2,
        (max.getZ() - min.getZ())/2
        );
That's not in the middle, except in some special cases. It's half the vector from one to the other. The division by 2 is pretty pointless if the only thing you're going to do is call atan2.

I'm still not quite sure what you're trying to do. Compute Euler angles for a look vector?
Offline Roquen
« Reply #5 - Posted 2010-12-07 12:46:07 »

I'm still not understanding the question.  If it is "What's the angle between 'A' & 'B'", then like SimonH's reply - use the dot product (SEE: Geometric interpretation).
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (11 views)
2014-07-30 21:08:39

Riven (21 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (32 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (29 views)
2014-07-23 21:07:15

Riven (30 views)
2014-07-23 20:56:16
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!