i have two bezier curves placed at a distance apart in space.
curve 1 has control points A0, A1,A2, A3. A0 and A3 lie on curve and are its end points
Curve 2 has control points C0,C1, C2, C3 . C0 and C3 lie on curve.and are its end points
i want to join the two curves A and C with an intermediate bezier curve B. the intermediate Curve B has control points A3 and C0 which lie on the curve and are its end points. the intermediate control points B1 and B2 are unknown to me. also the joining should be smooth enough. please help as to how to proceed. have read alot about beziers but dont know how to do this.
thanks and regards,
Gauri
B1 will be: B1x = 2 * A3x - A2x; B1y = 2 * A3y - A2y;
B2 will be: B2x = 2 * C0x - C1x; B2y = 2 * C0y - C1y;
This should give you perfectly smooth join.
#Arty
You are correct but this will only assure a "smooth enough" join.
To achieve a better looking join of those 2 curves you must also have 2nd derivative equals at the junction points. I place this here for those that might need this piece of information.
Related
For a Bezier curve I know the P0,P1 and the
control point P2. (and I can calculate the Q0)
I want to find for a new curve, with Q1(t=0,25) == Q0(t=0,25),
P0==Q0(t=0.25) and P1==Q0(t=0.75),
the new control point P2.
I re-edit my initial post. I've added a picture.
In the picture the blue and red dots are my initial P0 and P1 points and the green dot is the initial control point P2.
Now, I want to find the new control point P2' if I now the purple points P1' and P2'.
In essence I want to draw 2 new curves,
a) from red point to first purple point and
b) from blue point to the second purple point
Any idea?
The question is a bit convoluted but I will give it a shot. To me it seems that OP wants the control points of the segment of the original curve from the parameter value t = 0.25 up to the parameter value t=0.75. This can be achieved using De Casteljau's algorithm twice. Since I haven't found a step-by-step version for quadratic curves on SO, I made one.
Step 0: Take your three control points (note that I name them in a more usual order but I use OP's colour scheme).
Step 1: Use De Casteljau's algorithm for t=0.25. This means that
P_01 = 0.25 * P_0 + (1 - 0.25) * P_1,
P_12 = 0.25 * P_1 + (1 - 0.25) * P_2 and
P_012 = 0.25 * P_01 + (1 - 0.25) * P_12.
Note the purple colour signifying that my P_012 corresponds to the left of OP's purple points.
Step 2: Rename things to simplify writing the second run of the algorithm.
Step 3: Use De Casteljau's algorithm for the second time. But be careful: the parameter value t=0.75 of the original curve corresponds to the parameter value t=2/3 of what is left from it. This means that
P'_01 = 2/3 * P'_0 + (1 - 2/3) * P'_1,
P'_12 = 2/3 * P'_1 + (1 - 2/3) * P'_2 and
P'_012 = 2/3 * P'_01 + (1 - 2/3) * P'_12.
Step 4: Rename things again and pick up the results:
P''_0 is the left of OP's purple points,
P''_1 is the green point OP is looking for and
P''_2 is the right of OP's purple points.
Hi so I have a problem from my differential equations class that I am having difficulty solving with the improved Euler's method:
The logistic equation for the population (in thousands) of a certain species is given by dP/dt = 2P-2P^2. With t being time variable in years
Given P(0) = .5, with step size h = .2 (so .2 of t), find population at 1 year.
I used the normal Euler's method and got 634 but am not sure how to implement the modified Euler's method on the given differential equation.
The improved Euler method or explicit midpoint method has two stages
Stage one is an Euler step with half the step size
Stage two is the full step with the slope from the point from step one.
So if dP/dt = Q(P) then
k1 = Q(P0)
k2 = Q(P0 + h/2 * k1)
P1 = P0 + h * k2
or
Phalf = P0+h/2*Q(P0)
P1 = P0 + h*Q(Phalf)
I have the start and end points and the values of the slope of the curve at those points.
Now I have to draw a "smooth 2D bezier curve" through the two given points.
Now how to locate the two control points to achieve this. Is there any way for it? I know that the control points must lie on the tangents at the respective start and end points.
Note:By "smooth curve", I meant that there should be no steep curves or turnings in the final plot.
It sounds like you have catmull-rom curve coordinates (two points, and their departure and arrival tangents), in which case https://pomax.github.io/bezierinfo/#catmullconv covers all the math necessary to convert those to Bezier coordinates. And if you don't care about the "how", just skip to the end of the section for the straight up conversion rules.
tl;dr version: rewrite your coordinates to Catmull form:
[P1, v1, v2, P2] -> [P1 - v1, P1, P2, P2 + v2]
Then we convert that to Bezier coordinates:
P1 <= P1
p2 <= P1 - (P2 - P1 - v1) / 6 * f
p3 <= P2 + (P2 + v2 - P1) / 6 * f
p4 <= P2
the f is a tension constant. Play around with that. It's usually 1, but it might not be depending on how strong those tangents were.
For a cubic Bezier curve defined by P0, P1, P2 and P3 where P0 and P3 are the start point and end point, its first derivative vector at t=0 and t=1 are
C'(t=0) = 3*(P1-P0)
C'(t=1) = 3*(P3-P2)
So, if you already know the slope at the start and end point, you can easily convert that to tangent vectors and find the control points P1 and P2. You do need to assign a proper magnitude for the first derivative vectors so that the final resulting curve does not have inflection point. But as long as you make sure the resulting control polygon formed by P0, P1, P2 and P3 are convex, then your cubic Bezier curve should be smooth and has no turnnings.
Background: I have a categorical variable, X, with four levels that I fit as separate dummy variables. Thus, there are three total dummy variables representing x=1, x=2, x=3 (x=0 is baseline).
Problem/issue: I want to test the significance of a linear combination of my model's parameters, something like: 2*B1+2*B2+B3=0.
In Stata, the first issue can be done easily after a model is fit using the following:
test 2*B1 + 2*B2 + B3 = 0
Now, if I want to do this in SAS for PROC GLM using a CONTRAST statement, I know my "weights" (for lack of a better term) must sum to 0. For example, if, in an unrelated example, I wanted to test the following for four continuous variables: C1 + C2 = C3 + C4, my contrast statement would look like:
CONTRAST 'Contrast1' C1 0.5 C2 0.5 C3 -0.5 C4 -0.5
In this case, it's obvious how each variable should be weighted. However, when I want to combine the coefficients I gave in the model above (2*B1 + 2*B2 + B3 = 0) with these weights, it becomes unclear to me how to weight the function in the CONTRAST statement, specifically for a dummy variable-coded categorical variable, as described initially in the problem.
Use PROC REG.
proc reg data=mydata;
model y = b1 b2 b3;
test 2*b1+2*b2+b3=0;
run;
quit;
I have been learning about camera calibration and get confused in my way to understand how to recover extrinsic and intrinsic camera parameter from camera projection matrix.
In general, we can derive camera projection matrix values by solving the equations from correspondences of 3D world coordinates to 2D screen coordinates and that is, we get an matrix let's say "C"
C = [c11 c12 c13 c14; c21 c22 c23 c24; c31 c32 c33 c34]
And ussually, without loss of generality we can assign c34 = 1 and we can find the rest of the elements through correspondences 3D-2D.
After that, we can compare camera projection matrix C to conjunction of ext and int matrix (let's say M) that can be arranged to be
M = [fxr1+uxr3 fxtx+uxtz; fyr1+uyr3 fytx+uytz; r3 tz] where r1, r2, r3 are the row vector of Rotation matrix and tx,ty,tz are translation.
What I could not make out is when we compare each of C elements to M elements to get the ext and int parameter, our tz (translation about z) will be 1 because we have assigned c34 prior to be 1. How can the tz always 1? can anyone explain?
Look up "RQ decomposition". OpenCV has a routine to do it