File:Swastika curve.svg

Summary

Description
English: The Swastika curve plotted using 79 data points in first quadrant and repeated using symmetry.
Date
Source Own work
Author Krishnavedala
Other versions Image:Swastica_curve3.png
SVG development
InfoField

Source Code

#include    <stdio.h>
#include    <stdlib.h>
#include    <math.h>
#include    <unistd.h>
#include    <plplot/plplot.h>

long unsigned int NUM_PTS = 10000;
PLINT XMAX = 2;
PLINT YMAX = 2;

void generateCurve(PLFLT *x, PLFLT *y)
{
    int i = 0;
    double r, theta=0.f;
    float step = 2*PI/NUM_PTS;
    float s, c;
   
    while(theta < 2*PI)
    {
        s = sin(theta);        c = cos(theta);
        r = sqrt(s * c / (pow(s,4) - pow(c,4)));
        x[i] = (PLFLT) (r * cos(theta));
        y[i] = (PLFLT) (r * sin(theta));
        /*
        x[i] = (PLFLT) cos(theta) * sqrt(-1/sin(theta*4)) * modulus(sin(2*theta));
        y[i] = (PLFLT) sin(theta) * sqrt(-1/sin(theta*4)) * modulus(sin(2*theta));
        */
        theta += (double) step;
        i++;
    }
}

int main(void)
{
    PLFLT *X = NULL, *Y = NULL;
    plscolbg(255, 255, 255);
    plsdev("wxwidget");
    plinit();   // initialize plotting library
    plscol0(15, 0, 0, 0);
    plcol(15);
    plenv(-XMAX, XMAX, -YMAX, YMAX, 1, -2);
    plbox( "abcstn", 0, 0, "anbcst", 0, 0);
    pllab("X", "Y", "Swastika Curve");
    X = (PLFLT*) malloc(NUM_PTS * sizeof(PLFLT*));
    Y = (PLFLT*) malloc(NUM_PTS * sizeof(PLFLT*));
    if(X == NULL &#x7C;&#x7C; Y == NULL) 
    {
        perror("Unable to allocate memory!!");
        free(X);   free(Y);     exit(1);
    }
    generateCurve(X, Y);
    plline(NUM_PTS, X, Y);
    plend();    // close the plotting library
    { free(X);   free(Y); }
    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#Swastika%20curve.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#Swastika%20curve.svgCategory:GFDL#Swastika%20curve.svg
You may select the license of your choice.
Category:Self-published work Category:Quartic curves Category:Images with C source code Category:SVG mathematics
Category:CC-BY-SA-3.0 Category:GFDL Category:Images with C source code Category:License migration redundant Category:Quartic curves Category:SVG mathematics Category:Self-published work Category:Valid SVG created with Text Editor