Table of Contents



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:

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

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.


//    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: 2017/02/22 18:30 (external edit)

Access website using Tor Access website using i2p

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