Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (549)
Games in Android Showcase (137)
games submitted by our members
Games in WIP (594)
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 1645 times)
0 Members and 1 Guest are viewing this topic.
Offline 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?
Offline 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
Offline SimonH
« Reply #2 - Posted 2010-12-06 21: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 03: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 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?
Offline 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.

GamerIDGoesHere (20 views)
2015-01-27 01:23:23

GamerIDGoesHere (19 views)
2015-01-27 01:22:15

CopyableCougar4 (25 views)
2015-01-27 00:34:41

CopyableCougar4 (16 views)
2015-01-26 04:47:56

Olo (14 views)
2015-01-25 21:26:00

Olo (16 views)
2015-01-25 18:44:22

Robo11 (30 views)
2015-01-25 06:14:26

basil_ (27 views)
2015-01-17 22:29:32

wxwsk8er (26 views)
2015-01-16 21:42:21

wxwsk8er (22 views)
2015-01-16 20:44:20
2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17 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‑
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!