## Code Excerpt for Texture Model Star

    Scalar Tips;   // in [4 .. 10] stepsize 1
    Scalar Radius; // in [0 .. 1] stepsize 0.1
    Scalar Number; // in [3 .. 8] stepsize  1

    void TextureStar::setupParameter(const std::vector<Scalar> &parameter){

        tips_ = boost::math::round(Tips);

        radius_max_ = 0.2 + Radius*0.4;
        radius_min_ = 0.1 + 0.1 * radius_max_;
        number_ = Number;

    }

    //Implementation based on:
    //Ebert, David S. Texturing & Modeling a Procedural Approach. San Francisco, Calif.: Morgan Kaufmann, 2003.

    Scalar TextureStar::evaluate(const Scalar &x_norm, const Scalar &y_norm){

        Scalar value = 1.0;

        Scalar coord_x = fabs(x_norm);
        Scalar coord_y = fabs(y_norm);

        // scale coordinates
        coord_x *= number_;
        coord_y *= number_;

        Scalar angle, r, a;
        Scalar starangle = 2*M_PI/ (Scalar) tips_;
        Eigen::Vector3d p0(cos(0),sin(0),0);
        p0*=radius_max_;
        Eigen::Vector3d p1(cos(starangle/2.0),sin(starangle/2.0),0);
        p1*=radius_min_;
        Eigen::Vector3d d0(p1 - p0);
        Eigen::Vector3d d1;

        Scalar x_cell = floor(coord_x);
        Scalar y_cell = floor(coord_y);

        Scalar xx;
        Scalar yy;

        Scalar xx_repeat = coord_x - x_cell;
        Scalar yy_repeat = coord_y - y_cell;

        Scalar x_offset = 0.5;
        Scalar y_offset = 0.5;

        xx = xx_repeat - x_offset;
        yy = yy_repeat - y_offset;
        angle = atan2(xx, yy) + M_PI;
        r = sqrt(xx*xx + yy*yy);

        a = fmod(angle, starangle)/(Scalar)starangle;

        if (a >= 0.5) a = 1 - a;
        d1 << cos(a), sin(a),0;
        d1*=r;
        d1-=p0;

        value = step(0.0, d0.cross(d1)[2]);

        return value;

    }