Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have randomly generated sin values using angles:
sin(12)
sin(33)
sin(75)
sin(125)
...
I want to add a fixed rotation to all of these and wondering if there is an elegant way to do this? I was thinking of doing some comparisons and checks to see if the angle + my_additional_angle is negative and greater than certain values so as to add my fixed angle appropriately but wanted to ask for a simpler way first.
Also this has to be solved within these constraints, i.e. I can't use matrices, etc, because the application that defines these is very limited.
Lastly the random angle is between 0 and 180. The angle I am adding can be anything.
First off, trig functions work in radians, not degrees, so you almost certainly want:
sin(radians(12))
sin(radians(33))
# etc
To add an angle, if you do so before you take the sin it's really easy, just
sin(radians(12+angle))
sin(radians(33+angle))
It should not matter if the angle if negative or greater than 360, sin will still work correctly, so that sin(radians(12)) == sin(radians(12+360)) == sin(radians(12-360)).
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
My vehicle is driving along it’s locale Y-axis. When it encounters a hill the front lifts up and creates an angle with the rear. How can I ask python to return the angle for the vehicle to rotate on its X-axis ?
I found this but it doesn't work :
mathutils.geometry.box_fit_2d(points)
Returns an angle that best fits the points to an axis aligned rectangle
Parameters
points (list) – list of 2d points.
Returns
angle
Return type
float
to get the angle of the line you can pretty easily do it with a simple math
y1=kx1+l
y2=kx2+l
y1=kx1+y2-kx2
k=(y1-y2)/(x1-x2)
and this k is your tangent. so you just use numpy arctan
import numpy as np
angle=np.arctan((y1-y2)/(x1-x2))[0]
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Using Python, I want to check whether a circle has an equal radius along all 360 degrees. Actually, I have segmented a circular shape from an image and then want to check whether it has a same-sized and equal radius along all the 360 degrees or not.
Can someone kindly help and tell how to do that?
In Python, OpenCV is a strong choice for an imaging library. You'd want to fit a contour to the circle and use moments to check the properties. You can fit an ellipse and see how close the major and minor axis of the ellipse match.
See this tutorial/docs for details.
Also, this question should help.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
To be concrete, given 2D numerical data as is shown as line plots below. There are peaks on a background average movement (with small vibrations). We want to find the values of pairs (x1, x2) if those peaks drops down to average; or (x1) only if the line doesn't back to the average.
There are thousands of such 2D data.
What is the right statistic or machine learning algorithm to find x1 and x2 above without plotting?
Note that this is not an exact answer.
I seriously have no idea what you are trying to do. But I can suggest you a way. Assuming that there is only one peak in the graph and you have all the 2D points data i.e; (X1,Y1)...(Xn,Yn)...
Try calculating the differences between the Y values of adjacent points and get the minimum value if you are doing Yn-1 - Yn (which indicates starting point of the peak). Similarly, get the maximum value which indicates the points with the decreasing peak.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need a way to get a list of all sprites in a certain area of the screen, and I cannot find one anywhere on the internet.
Can someone please give me an example code of how to do this?
If it helps, all the sprites are in an "active" list.
Depends on whether you have obstacles or not, i.e. what the definition of "In the Area" means and also home many sprites you are dealing with.
If there's not many sprites and the distance calc is fast then brute force is probably ok.
for sprite in sprites:
if something.distance(sprite) < THRESHOLD:
do_something_with_near_sprite(sprite)
If you have a lot of sprites have a look at quadtrees and things like that. If calculating the distance is complicated then you're probably going to want to look at A* algorithm. There are libraries for these things so you shouldn't have to implement them yourself unless you want to.
This is a pretty general question (prepare to have it voted down by others :)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am making simple game. (A matrix where players can take cells(x,y), only one player on one cell, and they acquire new cells after the player before). Every player has a unique color. I am trying to find out if one player has surrounded cells of other users. In which case all cells are going to change color. Is there any known algorithm for this problem, to check only when user plays a new move ?
I would suggest that you take a look at a flood fill algorithm, these are simple algorithms that searches from a start point and tries to fill the board. You would simply have to check if the fill algorithm can reach the end of the board or not.