angle

Calculate angle of triangle Python

我只是一个虾纸丫 提交于 2020-03-01 03:21:07
问题 I'm trying to find out the angle of the triangle in the following, I know it should be 90 degrees, however I don't know how to actually calculate it in the following: Here's what I've tried: angle = math.cos(7/9.899) angleToDegrees = math.degrees(angle) returns: 43.XX What am I doing wrong? 回答1: It's a little more compicated than that. You need to use the law of cosines >>> A = 7 >>> B = 7 >>> C = 9.899 >>> from math import acos, degrees >>> degrees(acos((A * A + B * B - C * C)/(2.0 * A * B))

Java - Detect Straight Lines with given Coordinates

心不动则不痛 提交于 2020-01-21 11:48:07
问题 ADDED INFO: I'm using the inside of a square as an arena. On start up, the square spawns in a random position, and rotation, and I can't access any of the squares attributes. I then have a moving object inside the square, that I'm building AI for, and I want the object to 'learn' where the arena walls are. Every time the object bumps into a wall, I get a touch return, so I know if its hit or not. I'm using this to map the global position of where the object hit the wall and save it ... After