Java-Gaming.org Hi !
 Featured games (83) games approved by the League of Dukes Games in Showcase (541) Games in Android Showcase (133) games submitted by our members Games in WIP (604) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 figureing out the x,y, and z rotation of a right triangle?  (Read 1639 times) 0 Members and 1 Guest are viewing this topic.
CyanPrime
 « Posted 2010-12-06 20: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?
pjt33
 « Reply #1 - Posted 2010-12-06 21: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
SimonH
 « Reply #2 - Posted 2010-12-06 21:44:47 »

or the dot product would do it.

People make games and games make people
CyanPrime
 « Reply #3 - Posted 2010-12-07 03:09:56 »

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

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()))
pjt33
 « Reply #4 - Posted 2010-12-07 09: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?
Roquen
 « Reply #5 - Posted 2010-12-07 11: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.
 Mr.CodeIt (10 views) 2014-12-27 04:03:04 TheDudeFromCI (14 views) 2014-12-27 02:14:49 Mr.CodeIt (25 views) 2014-12-23 03:34:11 rwatson462 (56 views) 2014-12-15 09:26:44 Mr.CodeIt (46 views) 2014-12-14 19:50:38 BurntPizza (92 views) 2014-12-09 22:41:13 BurntPizza (113 views) 2014-12-08 04:46:31 JscottyBieshaar (86 views) 2014-12-05 12:39:02 SHC (96 views) 2014-12-03 16:27:13 CopyableCougar4 (102 views) 2014-11-29 21:32:03
 Rayvolution 50x basil_ 29x HeroesGraveDev 28x BurntPizza 27x LiquidNitrogen 24x appel 18x kpars 18x princec 17x KevinWorkman 15x Riven 15x kevglass 13x NegativeZero 13x gouessej 13x pitbuller 12x KudoDEV 11x Ecumene 11x
 Resources for WIP gamesby kpars2014-12-18 10:26:14Understanding relations between setOrigin, setScale and setPosition in libGdx2014-10-09 22:35:00Definite guide to supporting multiple device resolutions on Android (2014)2014-10-02 22:36:02List of Learning Resources2014-08-16 10:40:00List of Learning Resources2014-08-05 19:33:27Resources for WIP games2014-08-01 16:20:17Resources for WIP games2014-08-01 16:19:50List of Learning Resources2014-07-31 16:29:50
 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