angle

start and end angle of UIBezierPath?

ⅰ亾dé卋堺 提交于 2019-12-04 01:33:28
I have coded as below for half circle in iOS using UIBezierPath and CAShapeLayer . clockWiseLayer = [[CAShapeLayer alloc] init]; CGFloat startAngle = -M_PI_2; CGFloat endAngle = M_PI + M_PI_2; CGFloat width = CGRectGetWidth(imageView.frame)/2.0f + 30; CGFloat height = CGRectGetHeight(imageView.frame)/2.0f +50; CGPoint centerPoint = CGPointMake(width, height); float radius = CGRectGetWidth(imageView.frame)/2+10; clockWiseLayer.path = [UIBezierPath bezierPathWithArcCenter:centerPoint radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES].CGPath; clockWiseLayer.fillColor = [UIColor

Getting angle back from a sin/cos conversion

非 Y 不嫁゛ 提交于 2019-12-04 00:22:52
I want to reverse a sin / cos operation to get back an angle, but I can't figure out what I should be doing. I have used sin and cos on an angle in radians to get the x/y vector as such: double angle = 90.0 * M_PI / 180.0; // 90 deg. to rad. double s_x = cos( angle ); double s_y = sin( angle ); Given s_x and s_y , is it possible to get back the angle? I thought atan2 was the function to use, but I'm not getting the expected results. atan2(s_y, s_x) should give you the correct angle. Maybe you have reversed the order of s_x and s_y . Also, you can use the acos and asin functions directly on s_x

Rotate marker based on driving direction

ぃ、小莉子 提交于 2019-12-03 17:09:18
问题 I have a marker in my Google Maps map that looks like this: When the user is driving, I want to rotate it based on his driving direction. How can I achieve this? I should probably use previous location and current location coords for calculation, but I have no idea how. 回答1: If you use GPS for locating the user then the Location object you get in onLocationChanged contains the bearing. If you only have the two coordinates (e.g. you only have coordinates from network location provider), you

Calculating angles between line segments (Python) with math.atan2

六眼飞鱼酱① 提交于 2019-12-03 14:12:15
I am working on a spatial analysis problem and part of this workflow is to calculate the angle between connected line segments. Each line segment is composed of only two points, and each point has a pair of XY coordinates (Cartesian). Here is the image from GeoGebra. I am always interested in getting a positive angle in 0 to 180 range . However, I get all kind of angles depending on the order of vertices in input line segments. The input data I work with is provided as tuples of coordinates. Depending on the vertex creation order, the last/end point for each line segment can be different. Here

How to render a svg circle using start and endAngle

▼魔方 西西 提交于 2019-12-03 13:54:50
问题 I have rendered the svg circle using start and endAngle. It was worked fine. But when i render the complete circle(startAngle as 70 and endAngle as 70) the output is huge different(except the 0, 90, 180, 270). what i made wrongly for this code? function getPathArc(center, start, end, radius) { end -= this.isCompleteAngle(start, end) ? 0.0001 : 0; var degree = end - start; degree = degree < 0 ? (degree + 360) : degree; return this.getCirclePath( center, getLocationFromAngle(start, radius,

How to use atan2() in combination with other Radian angle systems

╄→尐↘猪︶ㄣ 提交于 2019-12-03 13:50:41
问题 I am struggling with this in JavaScript, but this problem applies to many other languages/environments as well. I want to have one object rotating towards the position of another object, and I use: atan2(obj1.dy, obj1.dx) - obj2.getRotation() to check if the second object should rotate clockwise or counterclockwise at a given time. In KineticJS, the JS/HTML5/Canvas programming environment I am using, the angle is specified in radians from 0 to 2 pi starting at the positive Y axis and going

Svg matrix decomposition

☆樱花仙子☆ 提交于 2019-12-03 13:33:07
In svg we have method element.getCTM() which returns a SVGMatrix as: [a c e][b d f][0 0 1] I want to calculate sx , sy and angle of rotation from this matrix. There is a lot to read and learn on this subject. I'll give a basic answer, but be aware, if you are trying to do a game or animations this is NOT the way to do it. a == sx and d == sy , so you'll access these like this: var r, ctm, sx, sy, rotation; r = document.querySelector('rect'); // access the first rect element ctm = r.getCTM(); sx = ctm.a; sy = ctm.d; Now for the rotation a == cos(angle) and b == sin(angle) . Asin and acos can't

Programming a smooth change of thrust from current velocity vector to a target vector

若如初见. 提交于 2019-12-03 09:55:44
问题 TL;dr: "I am not sure how to calculate a smooth transition of thrust between one vector and another." I am programming a simple game where an enemy chases after the player in an open space (no walls). I was calculating the enemy's x & y velocities independently, accelerating them if they were taking them in the direction of the player and quickly slowing them if they were going the wrong way (e.g. EnemyVelocity.x > 0 & player.x < enemy.x, then EnemyVelocity.x - 2.) While the gameplay is

Angle between 2 GPS Coordinates

瘦欲@ 提交于 2019-12-03 07:50:55
问题 I'm working in another iPhone App that uses AR, and I'm creating my own framework, but I'm having trouble trying to get the angle of a second coordinate relative to the current device position, anyone know a good resource that could help me with this? Thanks in advance! 回答1: If the two points are close enough together, and well away from the poles, you can use some simple trig: float dy = lat2 - lat1; float dx = cosf(M_PI/180*lat1)*(long2 - long1); float angle = atan2f(dy, dx); EDIT: I forgot

Periodic Data with Machine Learning (Like Degree Angles -> 179 is 2 different from -179)

两盒软妹~` 提交于 2019-12-03 07:42:40
问题 I'm using Python for kernel density estimations and gaussian mixture models to rank likelihood of samples of multidimensional data. Every piece of data is an angle, and I'm not sure how to handle the periodicity of angular data for machine learning. First I removed all negative angles by adding 360 to them, so all angles that were negative became positive, -179 becoming 181. I believe this elegantly handles the case of -179 an similar being not significantly different than 179 and similar,