How to generate squircle curve with two points and two tangent angle

734 Views Asked by At

The standard squircle curve equation is: $(x-a)^4 + (y-b)^4 = r^4$

What I do is not generating the whole curve, but just like AutoCAD, I give two points with two tangent angles respectively by clicking mouse on the screen. There is no problem if the two tangent angles are vertical, that is 0, 90, 180, 270, 360.see Pic.1

Pic.1 squircle curve with the vertical angle

But if the two tangent angles are not vertical, let's say the first one is 290 degree and the second one 65 is degree, I have no idea how to generate the curve with these information. The Pic.2 is a curve generated by one software use the unvertical tangent angle, as seen from the curve shape, I don't think that is a standard squircle curve, but I still wonder how can I generate a squircle curve with two points and two unvertical tangent angle. If there is anyone who is familiar with this, I hope you can give me some clue about this. and if my description is not clear, please let me know, I will try my best to let you understand.Thank you.

Pic.2 the squircle curve generated by unvertical tangent angle.

1

There are 1 best solutions below

5
On BEST ANSWER

As @Arentio already mentioned it is not possible to produce the second image with the given formula and axes that are rectangular to each other. But what You could do to produce that image is just applying an linear transform (or an affine transform, but you can absorb the "affine part" into $a$ and $b$).

Basically you know the tangents through $A$ and $B$ and you can easily determine their intersection $P$. Without loss of generality we can assume that $P=\vec{0}$. Then we just need to apply the a linear transformation $T$ that maps $\vec{PA}$ to $\vec{PA'}$ and $\vec{PB}$ to $\vec{PB'} $respectively. Then we are back in the "rectangular" case where we already have the means to draw the "squircle".

To map the basis $(\vec{PA},\vec{PB})$ to the cannonical basis we use the transformation matrix $U = (\vec{PA} \mid \vec{PB})$ and similarly to map the basis $(\vec{PA} \mid \vec{PB})$ to the cannonical basis we use the transformation matrix $V= (\vec{PA'} \mid \vec{PB'})$. So we could describe $T$ for the case $P=0$ as $T = UV^{-1}$ or for $P \neq 0 $ as $v \mapsto UV^{-1} (v-P) + P$.


EDIT: I'm gonna make some example calculations based on estimated values for the example above. In the following I omit the vector arrows and omit the transposed sign ()^t too for the sake of simplicity.

$P = 0$, $A = (1,1.5), PB = (-1,2)$. I assume that $A' = \Vert PA \Vert e_1 ,B' = \Vert PB \Vert e_2 $ i.e. $PA' = (1.80,0)$ and $PB' = (0,2.23)$, and so

$U = (PA \mid PB) = \begin{pmatrix} 1 & -1 \\ 1.5 & 2 \end{pmatrix}, V = (PA' \mid PB') = \begin{pmatrix} 1.80 & 0 \\ 0 & 2.23 \end{pmatrix}$

Then $T = UV^{-1} = \begin{pmatrix} 0.55 & -0.44 \\ 0.83 & 0.98\end{pmatrix}$

So in this case we transform the coordinate system with $T$

$$ \begin{pmatrix} r \\ s \end{pmatrix} = T^{-1} \begin{pmatrix} x \\ y \end{pmatrix} = \begin{pmatrix} 1.2019x + 0.4006y \\ -1.0541x+0.7027y \end{pmatrix} $$

Then the squircle in the image above is given by the equation $(r-a)^4+(s-b)^4 = r^4$ for some $a,b$ and $r$.