degrees

How to compute correctly rounded trigonometric functions in degrees?

北慕城南 提交于 2019-11-30 13:58:26
How could I define trigonometric functions that take arguments in degrees instead of the usual radians, and compute correctly rounded results for these arguments? Multiplying the argument by M_PI/180.0 before passing it to the corresponding function in radians does not work, because M_PI/180.0 is not π/180. Section 5.5 of the Handbook of Floating-Point Arithmetic offers a method to compute the correctly rounded product of the argument by π/180, but some arguments will still be such that this product is close to the midpoint between two consecutive representable floats, and then applying even a

calculating angle between two points on edge of circle Swift SpriteKit

寵の児 提交于 2019-11-30 13:00:50
How would you calculate the degrees between two points on the edge of a circle in Swift. Given points p1 , p2 on a circle with center center , you would compute the difference vectors first: let v1 = CGVector(dx: p1.x - center.x, dy: p1.y - center.y) let v2 = CGVector(dx: p2.x - center.x, dy: p2.y - center.y) Then let angle = atan2(v2.dy, v2.dx) - atan2(v1.dy, v1.dx) is the (directed) angle between those vectors in radians, and var deg = angle * CGFloat(180.0 / M_PI) the angle in degrees. The computed value can be in the range -360 .. 360, so you might want to normalize it to the range 0 <=

Rotate point about another point in degrees python

巧了我就是萌 提交于 2019-11-30 04:34:36
If you had a point (in 2d), how could you rotate that point by degrees around the other point (the origin) in python? You might, for example, tilt the first point around the origin by 10 degrees. Basically you have one point PointA and origin that it rotates around. The code could look something like this: PointA=(200,300) origin=(100,100) NewPointA=rotate(origin,PointA,10) #The rotate function rotates it by 10 degrees The following rotate function performs a rotation of the point point by the angle angle (counterclockwise, in radians) around origin , in the Cartesian plane, with the usual

How to compute correctly rounded trigonometric functions in degrees?

ぐ巨炮叔叔 提交于 2019-11-29 19:36:46
问题 How could I define trigonometric functions that take arguments in degrees instead of the usual radians, and compute correctly rounded results for these arguments? Multiplying the argument by M_PI/180.0 before passing it to the corresponding function in radians does not work, because M_PI/180.0 is not π/180. Section 5.5 of the Handbook of Floating-Point Arithmetic offers a method to compute the correctly rounded product of the argument by π/180, but some arguments will still be such that this

Rotating a CGPoint around another CGPoint

这一生的挚爱 提交于 2019-11-29 14:23:15
Okay so I want to rotate CGPoint(A) 50 degrees around CGPoint(B) is there a good way to do that? CGPoint(A) = CGPoint(x: 50, y: 100) CGPoint(B) = CGPoint(x: 50, y: 0) Here's what I want to do: This is really a maths question. In Swift, you want something like: func rotatePoint(target: CGPoint, aroundOrigin origin: CGPoint, byDegrees: CGFloat) -> CGPoint { let dx = target.x - origin.x let dy = target.y - origin.y let radius = sqrt(dx * dx + dy * dy) let azimuth = atan2(dy, dx) // in radians let newAzimuth = azimuth + byDegrees * CGFloat(M_PI / 180.0) // convert it to radians let x = origin.x +

calculating angle between two points on edge of circle Swift SpriteKit

大城市里の小女人 提交于 2019-11-29 12:27:20
问题 How would you calculate the degrees between two points on the edge of a circle in Swift. 回答1: Given points p1 , p2 on a circle with center center , you would compute the difference vectors first: let v1 = CGVector(dx: p1.x - center.x, dy: p1.y - center.y) let v2 = CGVector(dx: p2.x - center.x, dy: p2.y - center.y) Then let angle = atan2(v2.dy, v2.dx) - atan2(v1.dy, v1.dx) is the (directed) angle between those vectors in radians, and var deg = angle * CGFloat(180.0 / M_PI) the angle in degrees

Convert an angle in degrees, to a vector

北慕城南 提交于 2019-11-29 10:24:40
I'm doing some game programming. FWIW I'm using XNA, but I'm doubtful that this is relevant. I'd like to convert degrees to a directional vector (ie X and Y) with magnitude 1. My origin (0,0) is in the upper left. So I'd like 0 degrees to convert to [0, -1] I thought the best way to do this was to take my definition of North/Up and rotate it using a matrix, but this does not seem to be working. Here is the Code... public class Conversion { public static Vector2 GetDirectionVectorFromDegrees(float Degrees) { Vector2 North= new Vector2(0, -1); float Radians = MathHelper.ToRadians(Degrees); var

Lat Long to Minutes and Seconds?

老子叫甜甜 提交于 2019-11-28 13:30:35
Google Maps gives me the Lat and Long of a location in decimal notation like this: 38.203655,-76.113281 How do I convert those to Coords (Degrees, Minutes , Seconds) 38.203655 is a decimal value of degrees. There are 60 minutes is a degree and 60 seconds in a minute (1degree == 60min == 3600s). So take the fractional part of the value, i.e. 0.203655, and multiply it with 60 to get minutes, i.e. 12.2193, which is 12 minutes, and then repeat for the fractional part of minutes, i.e. 0.2193 = 13.158000 seconds. Example in python: def deg_to_dms(deg): d = int(deg) md = abs(deg - d) * 60 m = int(md)

Rotating a CGPoint around another CGPoint

倾然丶 夕夏残阳落幕 提交于 2019-11-28 08:13:24
问题 Okay so I want to rotate CGPoint(A) 50 degrees around CGPoint(B) is there a good way to do that? CGPoint(A) = CGPoint(x: 50, y: 100) CGPoint(B) = CGPoint(x: 50, y: 0) Here's what I want to do: 回答1: This is really a maths question. In Swift, you want something like: func rotatePoint(target: CGPoint, aroundOrigin origin: CGPoint, byDegrees: CGFloat) -> CGPoint { let dx = target.x - origin.x let dy = target.y - origin.y let radius = sqrt(dx * dx + dy * dy) let azimuth = atan2(dy, dx) // in

Convert an angle in degrees, to a vector

喜欢而已 提交于 2019-11-28 03:34:15
问题 I'm doing some game programming. FWIW I'm using XNA, but I'm doubtful that this is relevant. I'd like to convert degrees to a directional vector (ie X and Y) with magnitude 1. My origin (0,0) is in the upper left. So I'd like 0 degrees to convert to [0, -1] I thought the best way to do this was to take my definition of North/Up and rotate it using a matrix, but this does not seem to be working. Here is the Code... public class Conversion { public static Vector2 GetDirectionVectorFromDegrees