Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6650773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:55:56+00:00 2026-05-26T00:55:56+00:00

Suppose I have an explicit equation that could represent an object shape in OpenGL,

  • 0

Suppose I have an explicit equation that could represent an object shape in OpenGL, how should I sort of “plot” out the shape from the explicit equation?

For example, I have this explicit equation:
enter image description here

Both u and v are members of the real numbers.

I then tried to do this in OpenGL C++:

float maxParts = 20;

vector<float> point(3);

glBegin(GL_QUAD_STRIP);
for(int i=0; i<=maxParts; i++) {
    float u = ((float)i/maxParts)*2*M_PI;
    for(int j=-maxParts; j<=maxParts; j++) {
        float v = (j/maxParts) * M_PI;
        point[0] = cos(u) * (4.0+3.8*cos(v));
        point[1] = sin(u) * (4.0+3.8*cos(v));
        point[2] = (cos(v) + sin(v) - 1.0) * (1.0 + sin(v)) * log(1.0-M_PI*v/10.0) + 7.5 * sin(v);
        glVertex3f(point[0], point[1], point[2]);
    }
}
glEnd();

But it turns out to be just really crappy. The above code somewhat gives a slight impression of the shape but the polygons are not rendered properly. How should I iterate through the explicit equation for the x, y and z coordinates to construct the shape from the equation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:55:56+00:00Added an answer on May 26, 2026 at 12:55 am

    You’re generally going into the right direction. However you missed the crucial step, that you’ll have to split down the patch into smaller quads (tesselate it). So you don’t just iterate over the sampling points, you iterate over the patches and must generate 4 sampling points for each patch.

    Also you need to supply the vertex normals. The vertex normals are given by taking the cross product of the vectors δ{x,y,z}/δu and δ{x,y,z}/δv

    EDIT due to comment

    Code example for emitting independent quads:

    const int patches_x, patches_y;
    const float patch_size_x, patch_size_y;
    int px, py;
    for(px = 0; px < patches_x; px++) for(py = 0; py < patches_y; py++) {
        const float U = px * patch_size_x;
        const float V = py * patch_size_y;
        {
            float u, v;
            u = U - patch_size_x/2.0;
            v = V - patch_size_y/2.0;
            emit_quad_vertex(u, v);
        }
        {
            float u, v;
            u = U + patch_size_x/2.0;
            v = V - patch_size_y/2.0;
            emit_quad_vertex(u, v);
        }
        {
            float u, v;
            u = U + patch_size_x/2.0;
            v = V + patch_size_y/2.0;
            emit_quad_vertex(u, v);
        }
        {
            float u, v;
            u = U - patch_size_x/2.0;
            v = V + patch_size_y/2.0;
            emit_quad_vertex(u, v);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

suppose I have a class with many explicit (statically allocated) members and few pointers
Suppose I have a stringbuilder in C# that does this: StringBuilder sb = new
Suppose I have a class module clsMyClass with an object as a member variable.
Suppose I have: Toby Tiny Tory Tily Is there an algorithm that can easily
Suppose I have a table called Companies that has a DepartmentID column. There's also
Suppose you have an ACID database. Without an explicit guarantee about operation ordering, you
Suppose I wish to have 2 functions, one that generates a random integer within
Suppose that we have a pointer-to-class member pointing at a field of a class.
Suppose a Person object may have many Addresses but must have one Do you
Suppose I have a C# struct like this: [StructLayout(LayoutKind.Explicit)] struct IMAGE_DOS_HEADER { [FieldOffset(60)] public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.