how to find out the point of intersection of a circular arc and a circle - equation-solving

I have a circular arc.I know is centre radius and angle range.I need a matlab code to check whether a circle with known values intersects the arc and at which point they intersect.

Checkout Circle intersection equations. http://mathworld.wolfram.com/Circle-CircleIntersection.html

Related

Barycentric coordinates. Harmonic warping of a point relative to a concave polygon in C

I'm trying to get an array of weights that represent the influence a polygon's vertices have on an arbitrary position inside of it. With which I can interpolate the vertices of a deformed version of the polygon and get the corresponding deformed position.
Mean Value and Harmonic warping:
It seems that Harmonic coordinates would do this? My mesh goal:
I don't have easy time reading math papers. I found this Mathlab article, but still not grasping how to process each sampled position relative to the polygon's vertices
Meshlab article
Thanks!
You could try to create a Delaunay triangulation of the polygon and then use Barycentric coordinates within each triangle. This mapping is well defined and continuous, but in most cases probably not smooth (i.e. the derivative is not continuous).

How to calculate the coordinates of the centers of the smallest number of fixed radius circles that cover a rectangle?

In Cartesian coordinates I have a rectangle with a know height h, width w and 4 corners (x,y). If i have some value r that is the fixed radius of circles, how do I calculate the center points of the smallest number of circles that will totally cover the rectangle?
I think you should refer to existing approaches and choose one, you think is more suitable for you.
I recommend to start from this list of solutions for similar task - Circles Covering Squares
And, as you understand, because this optimization problem is more a mathematical than programmer, my second recommendation is to read related posts at mathematics forum

C logic/algorithm for circular and rectangular geofence?

I am trying to find out circular and rectangular geofence logic in C. (For circle, I will have fixed radius and centre coordinate) Please help me with some links/suggestions/replies.
For a circular geofence the easiest approach is to calculate the distance from the centre of the geofence to your current location. You'll know you're inside the geofence when that distance is less than the geofence radius. There are many methods that can be used to calculate the distance but How do I calculate distance between two latitude-longitude points? has some good examples.
For a rectangular geofence the question is essentially finding if the current position is within a polygon. The question Checking if a longitude/latitude coordinate resides inside a complex polygon in an embedded device? has a solution written in C# that would be trivial to convert to C. While it mentions a complex polygon the same technique will work for a rectangle.

Rotate Camera in the Direction behind object in OpenGL

I'm making a game in OpenGL, using freeglut.
I have a car, which I am able to move back and forward using keys and the camera follows it. Now, when I turn the car(glRotate in xz plane), I want the camera to change the Camera position(using gluLookAt) so it always points to the back of the car.
Any suggestions how do I do that?
For camera follow I use the object transform matrix
get object transform matrix
camera=object
use glGetMatrix or whatever for that
shift rotate the position so Z axis is directing where you want to look
I use object aligned to forward on Z axis, but not all mesh models are like this so rotate by (+/-)90 deg around x,y or z to match this:
Z-axis is forward (or backward depends on your projection matrix and depth function)
X-axis is Right
Y-axis is Up
with respect to your camera/screen coordinate system (projection matrix). Then translate to behind position
apply POV rotation (optional)
if you can slightly rotate camera view from forward direction (mouse look) then do it at this step
camera*=rotation_POV
convert matrix to camera
camera matrix is usually inverse of the coordinate system matrix it represents so:
camera=Inverse(camera)
For more info look here understanding transform matrices the OpenGL inverse matrix computation in C++ is included there.

Finding center of 2D triangle?

I've been given a struct for a 2D triangle with x and y coordinates, a rotation variable, and so on. From the point created by those x and y coordinates, I am supposed to draw a triangle around the point and rotate it appropriately using the rotation variable.
I'm familiar with drawing triangles in OpenGl with GL_TRIANGLES. My problem is somehow extracting the middle of a triangle and drawing the vertices around it.
edit: Yes, what I am looking for is the centroid.
There are different "types" of centers of a triangle. Details on: The Centers of a Triangle. A quick method for finding a center of a triangle is to average all your point's coordinates. For example:
GLfloat centerX = (tri[0].x + tri[1].x + tri[2].x) / 3;
GLfloat centerY = (tri[0].y + tri[1].y + tri[2].y) / 3;
When you find the center, you will need to rotate your triangle about the center. To do this, translate so that the center is now at (0, 0). Perform your rotation. Now reverse the translation you performed earlier.
I guess you mean the centroid of the triangle!?
This can be easily computed by 1/3(A + B + C) where A, B and C are the respective points of the triangle.
If you have your points, you can simply multiply them by your rotation matrix as usual. Hope i got you right.
There are several points in a triangle that can be considered to be its center (orthocenter, centroid, etc.). This section of the Wikipedia article on triangles has more information. Just look at the pictures to get a quick overview.
By "middle" do you mean "centroid", a.k.a. the center of gravity if it were a 3D object of constant thickness and density?
If so, then pick two points, and find the midpoint between them. Then take this midpoint and the third point, and find the point 1/3 of the way between them (closer to the midpoint). That's your centroid. I'm not doing the math for you.

Resources