POV-Ray : Newsgroups : povray.binaries.images : Elliptical torus : Re: Elliptical torus Server Time
26 Apr 2024 06:26:22 EDT (-0400)
  Re: Elliptical torus  
From: Bald Eagle
Date: 5 May 2020 20:20:01
Message: <web.5eb2022ba032ea3dfb0b41570@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

> I was also thinking that non-circular cross sections would be something nice to
> have - something like the form factors for the helix functions.  I have one
> function that I'll try to work out for that, but other functions similar to the
> superellipsoid, "squircle", and rounded box seem like they would have utility
> for povvers as well.

I made excellent progress in translating the function of main interest to into a
pattern and an isosurface.   I think in order to make it function as a
cross-sectional term, it needs to "translate its frame of reference to the
origin", and so I might need to convert the atan2 function to a polynomial.
But I might be wrong about that.

Essentially, I need to calculate the _angle_ that I'm at around the cross
section using x and y....
So I'd need to do something like this, only in SDL.


from:

https://stackoverflow.com/questions/11930594/calculate-atan2-without-std-functions-or-c99


float normalized_atan2( float y, float x )
{
    static const uint32_t sign_mask = 0x80000000;
    static const float b = 0.596227f;

    // Extract the sign bits
    uint32_t ux_s  = sign_mask & (uint32_t &)x;
    uint32_t uy_s  = sign_mask & (uint32_t &)y;

    // Determine the quadrant offset
    float q = (float)( ( ~ux_s & uy_s ) >> 29 | ux_s >> 30 );

    // Calculate the arctangent in the first quadrant
    float bxy_a = ::fabs( b * x * y );
    float num = bxy_a + y * y;
    float atan_1q =  num / ( x * x + bxy_a + num );

    // Translate it to the proper quadrant
    uint32_t uatan_2q = (ux_s ^ uy_s) | (uint32_t &)atan_1q;
    return q + (float &)uatan_2q;
}


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.