how to process sweeping surface whose section curve is a polygon? - polygon

I've got stumped by a question,recently.Now, I have a polygon and a NURBS Curve,then I want to make a sweeping surface that the NURBS Curve as a trojectory curve and the polygon as a section curve. Problem is the polygon can be triangle or quadrangle or others, that is it has N sides(N>=3).And a point on the NURBS curve is the circumcenter of a certain polygon. In order to do sweeping,I need to make a NURBS presentation for every polygon. If so, the workload is huge as the sides of polygon is undefined and the radius is also undefined. Have any good solutions?

Related

Fit surface to 3 to 100 points where z values are 3D

I found myself in quite a big problem. I am average in math and I need to solve something, which is not very covered on the internet.
My problem: I have 2D space defined by X and Y. This space is just a drawing space. I want to assign to particular Xs,Ys a color with RGB values.
So let says I have 4 points with defined position in XY and color in Z:
[0,0, [255,0,0]]
[0,10, [0,255,0]]
[10,10,[0,0,255]]
[5,5, [0,0,0]]
and my drawing space is xy: 15x15.
And I want to distribute the colors to all empty points
For me its quite a delicate problem, because Z axis is basicly 3D space by itself.
My whole intention is to create a color map in which points 1,2,3,4 have between them smooth transition.
I am able to solve this in 1D where the transition is between 2 points. But I need to create 2D color map in XY drawing space based on fitted surface to these 4 points, which kind of depend both on the space of 3D-RGB and distance between them in XY drawing space.
Thanks in advance for help
You do not show any algorithm or code, so I will just explain a high-level algorithm. If you need more details or code or mathematical formulae, show more of your own work then ask. You do not explain just what you mean by "smooth transition"--there are multiple meanings. This will result in continuous shading but may not be smooth enough for your purposes.
First, given your points in the rectangular drawing space, find the Voronoi diagram for those points. This divides the drawing space into convex polygons, each polygon around one of your points.
For each vertex in the Voronoi diagram, figure which points are closest to the vertex--there will usually be just three of your points but there could be more. Then at that vertex point, assign the color that is the average of the RGB values of the nearby given points. That is, average the R values and the G values and the B values separately.
For any point on a Voronoi polygon edge, its color is the weighted average of the two colors at the endpoints. I.e. If the point is one-third of the distance from one end, its RGB value is one-third of the distance from the values at the endpoints.
Finally, for any point inside a Voronoi polygon, calculate the ray from the point that defined that polygon (the "center point") through the current point you are looking at. Find where that ray intersects the polygon. The RGB value is then the weighted average of the values of the center point and the polygon-intersection point.
The hardest part of all that is finding the Voronoi diagram. Fortune's algorithm can do this in a reasonable time. You can probably find a library to do that for you in your chosen programming language.
Another algorithm is to start with a triangulation of your given points and the corners of the drawing region. Then the color of any point in a triangle is the weighted average of the colors of the vertices. This will be automatically consistent for points on the vertices or edges of the triangles, so this is probably simpler than my previous algorithm. The difficulty here is finding a triangulation (any will do).

Compute a radius scale factor to construct n-sided reqular convex polygons of equal area

I have a computer graphics plotting application where we often plot regular convex polygon shapes as symbols for different data points. I'd like to scale the radius (aka circumradius, distance from center to vertex) of the polygons so that polygons with different numbers of sides all have equal area (so presumably similar perceptual impact). i.e. if a circle with radius=1 has area Pi*radius^2, how much do I need to scale the radius to get a square or a triangle with the same area? What would the formula be to compute this for regular polygons with arbitrary numbers of sides?
Seems like this should be a simple geometry/algebra problem, but that was a long time ago... :-)
Using the formula below (taken from this site):
one can derive that:
R = sqrt(2*area / (N*sin(2*pi/N)))

Determining the cut of any given polygon and pyramid

I am trying to implement in C++ a function that determines the cut of any given polygon and pyramid.
This has actually turned out to be far simpler than I had first imagined.
Firstly for each edge of the pyramid, test line-plane intersection (the given polygon is a plane, made up of 3 points). This will result in the new vertices at the cutting plane.
Secondly, since the polygon is not an infinite plane one needs to test for line-line intersection between the polygon edges (three) and each of the edges.
Indeed, this is not a simple problem. For simplicity, let's assume that there are no parallel line segments.
First determine the plane where your convex polygon is in. Then detemerine the intersection of that plane with the pyramid. This results in a second convex polygon.
Now you should find the intersection of the two convex polygons. How this can be done, you can find here.

Depth interpolation for surface removal with perspective projection

This seems like a question for which an answer should readily available on the web or books but my quest for an answer has led me so far only to blind alleys that turned out to be dead ends.
I'm trying to draw 3D lines in real-time with hidden surface removal (the lines are edges of solid objects).
So I have two 3D points that were projected to 2D points using perspective projection. For each point I have computed the depth of the point. Now I want to draw the line segment that joins the 2 points, and for hidden surface removal to work I have to compute, for each intermediary 2D point on the 2D line (that results from the projection) the depth of the corresponding 3D point (the 3D point that is projected on that intermediary 2D point).
My problem is that, since the depth function isn't linear when you do perspective projection, I can't interpolate the depth of the 2 original 3D points to compute the depth of the intermediary point.
So how do I compute the depth of each point on the line with a method that's compatible with the constraints of real-time rendering?
Thanks in advance for any help.
Use homogeneous coordinates, which can be linearly interpolated in screen space: http://www.cs.unc.edu/~olano/papers/2dh-tri/

Finding the bounding box (axially aligned) of a parametric range of a 3D NURBS surface

I'll apologize in advance in case this is obvious; I've been unable to find the right terms to put into Google.
What I want to do is to find a bounding volume (AABB is good enough) for an arbitrary parametric range over a trimmed NURBS surface. For instance, (u,v) between (0.1,0.2) and (0.4,0.6).
EDIT: If it helps, it would be fine for me if the method confined the parametric region entirely within a bounding region as defined in the paragraph below. I am interested in sub-dividing those regions.
I got started thinking about this after reading this paragraph from this paper ( http://www.cs.utah.edu/~shirley/papers/raynurbs.pdf ), which explains how to create a tree of bounding volumes with a depth relative to the degree of the surface:
The convex hull property of B-spline surfaces guarantees that the surface is contained in the convex hull of its control mesh.
As a result, any convex objects which bound the mesh will bound the underlying surface. We can actually make a stronger
claim; because we closed the knot intervals in the last section [made the multiplicity of the internal knots k − 1], each nonempty
interval [ui; ui+1) [vj; vj+1) corresponds to a surface patch which is completely contained in the convex hull of
its corresponding mesh points. Thus, if we produce bounding volumes for each of these intervals, we will have completely
enclosed the surface. We form the tree by sorting the volumes according tothe axis direction which has greatest extent across the bounding volumes, splitting the data in half, and repeating the process.
Thanks! Sean
You will need to slice out a smaller NURBS surface, which only covers the parameter range you are interested in. Using your example, which I take to mean you are in the region where the u parameter is between 0.1 and 0.4. Let Pu be the degree of the spline in that parameter (A cubic spline has Pu = 3). You need to perform "knot insertion" (There's your Google search term) to get knots of degree Pu located at u=0.1 and u=0.4 Do the same thing on the v parameter to get knots of degree Pv at 0.2 and 0.6. The process of knot insertion will modify (and add to) the array of control points. There's a bit of bookkeeping involved, but you can then find the control_points that determine the surface in the parameter patch you just isolated between inserted knots. The convex property then says the surface is bounded by these control points, so you can use them to determine your bounding volume.
The NURBS reference I like to use for operations like this is: "The NURBS Book", by Les Piegl and Wayne Tiller.

Resources