File:Conchospiral.svg

Summary

Description
English: The conchospiral curve computed using C language and displayed and saved using PLplot library.
Source Own work
Author Krishnavedala

Source Code

#include <omp.h>
#include <stdio.h>
#include <math.h>
#include <plplot/plplot.h>

#define        NUM_PTS        500
#define        THETA0    M_PI
  
int main (void)
{
    char txtBuffer[30];
    PLFLT *X=NULL, *Y=NULL, *Z=NULL;
    X = (PLFLT*) malloc(NUM_PTS * sizeof(PLFLT*));
    Y = (PLFLT*) malloc(NUM_PTS * sizeof(PLFLT*));
    Z = (PLFLT*) malloc(NUM_PTS * sizeof(PLFLT*));
    if(X == NULL || Y == NULL)
    {perror("Unable to allocate memory space!"); exit(-1);}
   
    plstart("wxwidgets",1,1);
    plscol0(0, 255, 255, 255);
    plscol0(15, 0, 0, 0);
    plcol(15);
   
    unsigned int count=0;
    float temp, theta=-THETA0;
    int col = 1;
    float xmin=0.f, xmax=0.f, ymin=0.f, ymax = 0.f, zmin=0.f, zmax = 0.f;
    const float mu = 1.07, a = 1., c = 1.1;
    #pragma omp for
    for(count = 0; count < NUM_PTS; count++)
    {
        temp = pow(mu,theta);
        X[count] = temp * a * cos(theta);
        Y[count] = temp * a * sin(theta);
        Z[count] = temp * c;
        xmin = (xmin < X[count]) ? xmin : X[count];
        xmax = (xmax > X[count]) ? xmax : X[count];
        ymin = (ymin < Y[count]) ? ymin : Y[count];
        ymax = (ymax > Y[count]) ? ymax : Y[count];
        zmin = (zmin < Z[count]) ? zmin : Z[count];
        zmax = (zmax > Z[count]) ? zmax : Z[count];
        theta += (20*THETA0/NUM_PTS);
    }
    pladv(0);
    plvpor( 0.0, 1.0, 0.0, 0.9 );
    plwind( -1.0, 1.0, -1.0, 1.5 );
    plw3d( 1.0, 1.0, 1.2, xmin, xmax, ymin, ymax, zmin, zmax, 50, 35 );
    plbox3( "bstu", "x axis", 0.0, 0,
            "bstu", "y axis", 0.0, 0,
            "bstu", "z axis", 0.0, 4 );
    plcol(col); plline3(NUM_PTS,X,Y,Z); plcol(15);
    sprintf(txtBuffer, "Conchospiral (#fs#gm=%.2f, a=%1.1f, c=%1.1f#fs)", mu, a, c);
    plptex(0.,1.3, 0, 0, .5, (const char*)txtBuffer);
    plend();
   
    free(X); free(Y); free(Z);
    return 0;
}

Licensing

I, the copyright holder of this work, hereby publish it under the following licenses:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Category:CC-BY-SA-3.0#Conchospiral.svg
GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.
Category:License migration redundant#Conchospiral.svgCategory:GFDL#Conchospiral.svg
You may select the license of your choice.
Category:Self-published work Category:Spirals Category:3D computer graphics Category:Images with C source code Category:PLplot
Category:3D computer graphics Category:CC-BY-SA-3.0 Category:GFDL Category:Images with C source code Category:License migration redundant Category:PLplot Category:Pages using deprecated source tags Category:Self-published work Category:Spirals