i'm working on a 3D engine in Java as part of my studies. I want to implement TRS (Translation, rotation, scale) on a Tube, but I cant find out what is the proper way to do it. I can transform and rotate, but I dont know how to scale it. I have scale matrix, but i need to modify the height and radius of the newly scaled Tube, which I dont know their new values.
A cylinder is defined by a Ray and Radius. A ray is defined by origin point and direction vector.
A Tube is a finite cylinder, which has height.
A sphere for example, which is defined by origin point and radius, I thought of defining its scale by volume. So, if the old volume of a sphere was V_old, and its radius was R_old, and I scaled it by some number N, then the new scaled sphere's radius wold be: R_new = ([N*V_old]/[PI*3/4])^(1/3)
But since the Tube's volume equation have another variable H (Height), I have only 1 equation with 2 unknown variables (R_new and H_new).
How can I define a Tube\Cylinder's scale? Is the way i defined a Sphere scale good?
I'm starting to think the way I define scale for sphere\cylinder\other radial geometry is not good. I have the scale matrix,so i can scale the ray of the Tube. Maybe is there a way to calculate the new Radius and Height of a Tube after multiplying its ray by the scale matrix?
"Scaling" comes down to applying the linear transform
$$ h_{\lambda} \, : \, (x,y,z) \in \mathbb{R}^3 \; \mapsto \; (\lambda x, \lambda y, \lambda z) \in \mathbb{R}^3 $$
defined for any $\lambda > 0$.
In $\mathbb{R}^3$, the cylinder of radius $r > 0$ and height $R > 0$, centered at $(0, 0, 0)$, is defined as:
$$ C(r, R) = \left\{ (x, y, z) \in \mathbb{R}^3, \; x^2 + y^2 = r^2, \; -R/2 \leq z \leq R/2 \right\}. $$
The linear transformation $h_{\lambda}$ scales the cylinder $C(r, R)$ into the cylinder $C(r\lambda, R\lambda)$.
Indeed, if $(x, y, z) \in C(r, R)$, then $h_{\lambda}(x, y, z) = (x', y', z') = (\lambda x, \lambda y, \lambda z)$ satisfy to:
$$ x'^2 + y'^2 = r^2 \lambda^2 \quad \text{and} \quad -\frac{R \lambda}{2} \leq z' \leq \frac{R \lambda}{2}. $$
Therefore, $(x', y', z') \in C(r\lambda, R\lambda)$.