The blue dot and the blue area will need to be able to collide and to do so I need to calculate a path to create the physics body from.
I need help figuring out how I would create the path for the darker blue ring area (the darker portion of the ring within the light blue highlight).
I know it would have two arcs and two lines, but I need to be able to calculate the path based on the distance from the center and the angle (so in the image for example the angle would be 45 degrees, or PI/4, radius 1 would be 180px and radius 2 (the smaller one) would be 165px.
How would I create a dynamic path like this?
Related
I'm trying to calculate the distances between points of different colours, as shown in this image:
The goal is to use a macro to print the distances from the red dot to the yellow dot and then the yellow dot to the purple dot. I believe the best way to do this is to either:
1) Use a macro to print the coordinates of the red dots, and then a macro to print the coordinates of the closest yellow dots. Then a second macro to print the coordinates of the purple dots closest to a given yellow dot. I would also like to calculate the angle of the line relative to the center point, but I believe I can do this in Excel if I'm given the XY coordinates of each point as well.
2) Drawing lines between the red and yellow points and the yellow and purple points, printing the length and angle of those lines.
Ideally being able to do both would be good, but either would work for my purposes (calculating the distance and angle of the lines between the points from red to yellow and yellow to purple).
What is the best way to do this via macro? There are some examples (like this) but I don't believe it 1) selects for points based on colour or 2) picks the next closest point automatically.
Try using the Threshold Color function, I should think it would allow you to select your colors individually. You can then get the coordinates for your different points by selecting "centroid" from the Analyze menu. The calculations for the angles and distances can be done then in Excel if you use the closest coordinates for the relevant colors.
I am currently trying to map textures using image labels onto 2 different triangles (because im using right angle wedges so i need 2 to make scalene triangles), but here is the problem, I can only set positional, size, and rotational data so I need to figure out how I can use this information to correctly map the texture onto the triangle
the position is based on the topleft corner and size of triangle (<1,1> corner is at the bottom right and <0,0> corner is at top left) and the size is based on triangle size also (<1,1> is same size as triangle and <0,0> is infinitely tiny) and rotation is central based.
I have the UV coordinates (given 0-1) and face vertices, all from an obj file. The triangles in 3D are made up of 2 wedges which are split at a right angle from the longest surface and from the opposite angle.
I don't quite understand this however it may be help to change the canvas properties on the Surface GUI
Suppose one image like circle image is there. Then I want draw circle over that image, then check two image is same or not in iOS. I tried image matching using CGPoint, but for circle and triangle what to do.
For matching two triangles you may have two choices:
define two areas in each traingle, then calculate areas ratio, they must have the same ratio if they are matched
try to detect three points of each triangle, then calculate the barycentre coordinates
they are invarinat
For circle, if you could easily to represent each circle by a triangle which its points cross that circle, you can find the invariance by the previous steps.
I'm drawing squares along a circular path for an iOS application. However, at certain points along the circle, the squares start to go out of the circle's circumference. How do I make sure that the squares stay inside?
Here's an illustration I made. The green squares represent the positions I need the squares to actually be in. The red squares are where they actually appear given the following values for each square's upper-left corner:
x = origin.x + radius * cos(DEGREES_TO_RADIANS(angle));
y = origin.y + radius * sin(DEGREES_TO_RADIANS(angle));
Origin refers to the center of the circle. I have a loop that repeats this for every angle from 1 till 360 degrees.
EDIT: I've changed my design to position the centers of the squares along the circular path rather than their upper left corners.
why not just draw the centers of the squares along a smaller circle inside of the bigger one?
You could do the math to figure out exactly what the radius would have to be to ensure an exact fit, but you could probably trial and error your way there quickly too.
Doing it this way ensures that your objects would end up laid out in an actual circle too, which is not the case if you were merely making sure that one and only one corner of each square touched the larger bounding circle (that would create a slightly octagonal shape instead of a circle)
ryan cumley's answer made me realize how dumb I was all along. I just needed to change each square's anchor point to its center & that solved it. Now every calculated value for x & y would position every square's center exactly on the circular path.
Option 1) You could always find the diameter of the circle and then using Pythagorean Theorem, you could create a square that would fit perfectly within the circle. You could then loop through the square that was just made in the circle to create smaller squares, but I doubt this is what you are aiming for.
Option2) Find out what half of the length of one of the diagonals of the squares should be, and create a ring within the first ring. Then lay down squares at key points (like ever 30 degrees or 15 degrees, etc) along the inner path. Ex: http://i.imgur.com/1XYhoQ0.png
As you can see, the smaller (inner) circle is in the center of each green square, and that ensures that the corners of each square just touches the larger (outer) circle. Obviously my cheaply made picture in paint is not perfect, but mathematically it will work.
How to draw a circle overlapping another circle in the moved phase of touch event,such that no gap is left out between the circles.The circles must be tightly packed to one another,so that even when user moves his hand on the screen faster or lightly,no gap must be present between the circles.
Just two circles? Or many circles? If just two, then detecting if they overlap is simply verifying that their centers are not closer than the sum of their radii. For example, if Circle1's raduis is 10 pixels, and Circle2's radius is 25 pixels, then they overlap if the center of Circle1 is less than 35 pixels from the center of Circle2.
So if you do your calculations in the "moved" phase and find that they're too close, you have to adjust the position of one of them. How you go about that will depend on the specifics of your application. You could:
Keep the y coordinate of the moving circle the same, and calculate the necessary x coordinate to maintain the required distance.
Same as above but swap x and y.
As above, but move the "unmoving" circle away from the "moving" circle.
Some other calculation that makes sense for your application.
NOTE: You should accept some of the answers you've been given.