Intersecting points of curve! - c#

I am drawing an arc within a square or a polygon with the maximum possible radius inside.
When the arc is drawn within the boundary of the square or polygon,
the arc length will intersect at few points on the square or polygon.
How to find the coordinates of the intersecting points of arc at the periphery of the square/ polygon?

The line segment of the polygon has (or hasn't) a tangent point whose distance from the center point of the arc is the arc radius.
If that is the problem then project two lines parallel to the segment on either side of the segment at a distance of radius, then determine if either line intersects arc center point, if not, no tangent exists...
if so, the point of intersection relative to the projected segment is proportional to the tangent on the original segment.

The arc will intersect those segments of the boundary, which are of distance R from the center of the arc, where R is the radius of the arc. The intersection points are the projections of the center onto the given segments.
Therefore you can find all distances from the center to the segments and find those that match the radius. Then find the projections.

Related

Find max radius of an arc between two lines in 3D

I have found this solution to draw an arc between two points in 3D.
solution
Can anyone help to find a way how two limit the radius so the arc starts at max half distance of the shorter line
I have tried some simple geometry method of finding hal of angle between the lines and then calc the radius from r = tan(half_angle) but this works only for an angle close to 45 deg.
The maximum radius of an arc between two lines in 3D depends on the distance between the lines and the angle between them. The radius of the arc is given by: code example :
r = (d / 2) / sin(theta / 2)
Where d is the distance between the lines, and theta is the angle between the lines. The radius r is the maximum possible radius of the arc that can be formed between the lines, such that the arc lies in the plane that is perpendicular to the direction vectors of both lines and bisects the angle between the lines.

How to snap a point in the normal 3d grid to a point on a sphere coordinate

So I need to snap any floating point in 3D space to the nearest point on a sphere, the size of the sphere also needs to change as the point gets further from the origin, idk if that made sense or I'm just thinking about something incorrectly, but I made a picture of it in blender:
In the picture I have green dots which represent the possible places(there are more of them) that any point in space could snap to.. So how can I make any point in space snap to the closest green dot? And IK I could just loop through those points to check the closest one, but there are gonna be MANY of these points so its not a solution and so any point has to find its closest green dot without distance checks. An example of how this could work if I didn't need it to be on a sphere is this,
So lets say I have point x, and I want to snap it to its closest green dot(here the green dot isn't a point on a sphere but actually a point on a "cartesian" grid), so to snap point x I just do round(x / gridSize) * gridSize; and that snaps x to its closest grid point, but in my case I need it on a sphere, so how can I convert that to snap to a spehre? IDK if I'm making any sesne.
compute spherical coordinates a,b,r of point-center
where a=<0,2*PI> is longitude, b=<-PI/2,+PI/2> is latitude and r>=0 is radius
r=snapping_sphere_radius
snap a angle a= 2*PI*round(a*n/(2*PI))/n
where n is number snapping points on equator
snap b angle b= PI*round(b*m/PI)/m
where m is number of snapping circles (layers of sphere) usually m=n/2 ...
recompute Cartesian position of point from spherical (a,b,r) and add center

Find overlapped area between a circle and a group of polygons

I found some solutions to find the intersection between the circle and 1 triangle.
I am searching for a solution to find a more general solution, to find the area of the circle overlapped by the polygons present in the plan.
No 2 polygons intersect each other nor self-intersect.
A circle can be intersected (overlapped) by multiple polygons.
I would appreciate a C# solution.
Triangulate your polygons.
For each triangle i, compute the intersection area of your circle and triangle i. Call it A[i].
(You said you know how to do this part.)
The area of the intersection between your circle and your polygons is sum(A[i] for all triangles i).

Calculate rectangle's points from diagonal in 3D

I know 3 points in a 3D plane. Two points are the ends of a diagonal and an other one which is random point on the plane. How can I calculate the two other points of a rectangle from the known diagonal line? (Later I will use the points to calculate the perimeter of the rectangle in C#.)
There's no single right answer. All you can calculate using a diagonal and a random point on the plane is a whole sets of possible answers.
Imagine rotating the diagonal to create a circle - now every second line inscribed in that circle and going through the center can be the second diagonal. The only limit is your third point.
Since you know the end points of the diagonal, you can calculate the length of the diagonal; from there you can determine the rectangle side length; having diagonal coordinates and the side length, you can determine the other two points of the rectangle using add/subtraction.

How to hide/not draw part of the model

I have an animated model that's spinning.
I want to hide/not draw any part of the model that's Y<0
what are the ways I can do it?
ideas:
1) draw a giant rectangular box right below y=0
2) tweak the camera matrix so that y<0 is outside of clipping plane (but i have no idea how)
can someone point me into the right direction? =)
A purely mathematical approach:
Don't draw the polygons whose y's are all less than 0.
Draw the polygons whose y's are all greater than or equal to 0.
Clip the rest of the polygons with the y=0 plane and draw them.
If the polygons making up the model are triangles, clipping them is pretty trivial. You need to clip the two sides intersecting with the y=0 plane and replace the original vertices whose y's are less than 0 with the intersection points of those two sides with the clipping plane.
Use the line equations:
(x-x1) = (x2-x1)*(y-y1)/(y2-y1)
(z-z1) = (z2-z1)*(y-y1)/(y2-y1)
where 1 and 2 are the vertices of the side being clipped by the y=0 plane. Substitute their coordinates (x1, y1, z1, x2, y2, z2) and y=0 into the equations to get x and z of the intersection point. Use this point's coordinates instead of vertex 1's or 2's (whichever has y < 0).
If the polygons are texture-mapped, you'll need to recalculate the texture coordinates for the vertices that you got from the clipping. You do that in the same fashion.
It sounds like you need to introduce MSDN Bounding Frustum
Here is a good tutorial from Nic's GameDev Site.

Categories