Table of Contents

Graph

Theory

The code performs the follows the reasoning: for a chosen $a$, $b$ and $c$, select a random $x$ with $x \in [0, a)$, $y$ with $y \in [0, b)$ and $z$ with $z \in [0, c)$. If and only if the equation of the ellipsoid in standard form:

\begin{eqnarray*}
(\frac{x}{a})^{2} + (\frac{y}{b})^{2} + (\frac{y}{c})^{2} &\le& 1
\end{eqnarray*}

is satisfied, then the generated $x$ and $y$ values describe a point $(x, y, z)$ which lies within the elipsoid's perimeter. Otherwise, select new values for $x$, $y$ and $z$ and loop until the equation is satisfied.

Since we want, in this case, an upper elipsoid, all $z$ values must be positive.

Code

wasUpperEllipsoid.lsl
///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2016 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
vector wasUpperEllipsoid(float a, float b, float c) {
    float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(a);
    float y = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(b);
    float z = llFrand(c);
    if(llPow(x/a,2) + llPow(y/b,2) + llPow(z/c,2) <= 1)
        return <x, y, 0>;
    return wasUpperEllipsoid(a, b, c);
}

fuss/algorithms/geometry/point_generation/ellipsoid/upper_elipsoid.txt ยท Last modified: 2022/04/19 08:28 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.