GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #11  
Old 15-May-2007, 08:37
promsan promsan is offline
Junior Member
 
Join Date: May 2007
Location: North of the rhubarb triangle, GB
Posts: 53
promsan is on a distinguished road
Talking

Re: Linked Lists advice request


alright,

I've scrapped most of it and started again.

I've got a problem with my double-linked lists

Code:
typedef struct long_shape_type //this is my structure "shape_type" and contains the following bits of info: { int start_x1, start_y1; int start_x2, start_y2; int start_x3, start_y3; int colour; shape_type *prev; shape_type *next; }shape_type; // this is a nickname for the structure "long_line_type" this shape is passing these variables typedef struct long_line_type; { int start_x, start_y; int end_x, end_y; int colour; line_type *prev; line_type *next; }line_type; #include <stdio.h> #include "graphics_lib.h" #include <math.h> #include <conio.h> /*this is to move the current point up and down to search fr data.. this is the linked list bit for findig data*/ //First define "this_line" as a pointer. void display_shape(shape_type *this_shape) //"display_line" = "draw_line" {

I'm getting this set off errors (colour coded):
Quote:
--------------------Configuration: shapeshifter - Win32 Debug--------------------
Compiling...
shapeshifter.c
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(1 : error C2061: syntax error : identifier 'shape_type'
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(19) : error C2143: syntax error : missing '{' before '*'
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(20) : error C2059: syntax error : '}'
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(24) : error C2449: found '{' at file scope (missing function header?)
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(30) : error C2059: syntax error : '}'
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(40) : error C2143: syntax error : missing ')' before '*'
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(40) : error C2143: syntax error : missing '{' before '*'
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(40) : error C2059: syntax error : ')'

C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(41) : error C2054: expected '(' to follow 'this_shape'
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(266) : fatal error C1071: unexpected end of file found in comment
Error executing cl.exe.

shapeshifter.obj - 10 error(s), 0 warning(s)

the last one on line 266 is just the very last one of these "}"

Is that better?

cheers for all your help!
  #12  
Old 15-May-2007, 08:53
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,218
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Linked Lists advice request


Quote:
Originally Posted by promsan
The context of the error you asked about is
.
.
.
NB: I have changed the graphics_lib.h to sit betwixt " " rather than < > as you said.
So, why haven't you posted the code that you are currently running and tell us the current errors? Putting the right include statement apparently got rid of the original problem, then you post code that you ran previously and expect us to help with errors on some different code.
Quote:
Originally Posted by promsan
...aah see, from checking my old code I copied this from, I've changed "line_type" to "shape" but only on the typedef... time for some whittling...
No, it's not time for whittling. It's time for debugging.

I pasted the code of your most recent post below. I removed the markups and put it between [c]...[/c] tags instead of [code]...[/code] tags:

CPP / C++ / C Code:
#include <graphics_lib.h>
#include <math.h>
#include <conio.h>

//First define "this_line" as a pointer.
void display_line(line_type *this_line) //"display_line" = "draw_line"
{

 /* Open a graphics window */
 //initwindow(800, 600);
 /* Set the colour */
 setcolor(this_line->colour); //to set colour of line. the arrow dereferernces the *

 /* Draw the line
 line(this_line->start_x,this_line->start_y,this_line->end_x,this_line->end_y); //to set a co-ord to draw line
}
void get_line(line_type *line_pointer)        //line is a pointer to a line type
{

You can see from the syntax highlighter that it can't possibly give any of the symptoms that you have described.

This is impossibly wrong. I'm sorry that I can't help.

Since you haven't posted the code that you are currently using, how the heck could you expect meaningful help from an outsider?


Regards,

Dave
  #13  
Old 15-May-2007, 09:20
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,218
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Linked Lists advice request


Quote:
Originally Posted by promsan
alright,


I've got a problem with my double-linked lists
The error messages that you posted obviously are not for the code that you posted. The line numbers of the errors don't correspond to the erroneous lines in your code.

One last time: If you are going to expect meaningful help, I think you should post the code that you are actually running. Or, at least, indicate somewhere in your post what line numbers of the code that you show us correspond to error messages.
Here are the proper declarations for the structs that you showed:
CPP / C++ / C Code:
typedef struct long_shape_type {
    int start_x1, start_y1;
    int start_x2, start_y2;
    int start_x3, start_y3;
    int colour;
    struct long_shape_type *prev;
    struct long_shape_type *next;
} shape_type;

typedef struct long_line_type {
    int start_x, start_y;
    int end_x, end_y;
    int colour;
    struct long_line_type *prev;
    struct long_line_type *next;
} line_type;

#include <stdio.h>

int main()
{
    shape_type st;
    line_type lt;

    printf("Hi\n");
    return 0;
}

Note that I have posted a complete program that you can compile and verify proper syntax before getting to the "good stuff." The dummy main() is there just so that it can get a complete compilation. That is: the typedefs are correct, and you can actually declare variables of these types. All brackets are matched so that you don't have the 'unexpected end of file' error.

I respectfully suggest that you can do the same when building a program. Put new stuff in a little at a time. Compile. Make absolutely sure that there are no compiler errors or warnings before putting going on to the next step.

Don't put in dozens of lines or hundreds of lines between compiles. Just put typedefs or functions or some such thing and do a compile.

Regards,

Dave
  #14  
Old 15-May-2007, 14:35
promsan promsan is offline
Junior Member
 
Join Date: May 2007
Location: North of the rhubarb triangle, GB
Posts: 53
promsan is on a distinguished road

Re: Linked Lists advice request


sorry,

I'm just trying my best to give what I'm asked for. I am dyslexic, perhaps I misread or misinterpreted something (or take things too literally): it does often happen. (It certainly makes coding tricky - i missed that extra semi-colon I'd stuck into that structure)

Correct, the error messages are not for the complete code i listed at the start of the thread - I took HowardL literally and just posted exactly what I thought he asked for. Apologies for the confusion; and thanks for your efforts.

I've scrapped much of the previous code, and what I have now is shorter and clearer I think.
I'm using a linked list vector line drawing prog I wrote (that I know works) as the basis for this prog. (I appreciate your methodical approach, and I'll do my best to get my head into it).

I'll just post this; test yours; and post back in a sec'.

This is the code I have right now:
CPP / C++ / C Code:
/*
 * Shapeshifter (a vector graphics drawing programme by me)
 */

/*
 * Passing by reference
 */
#define PI = 3.142;

#pragma warning(disable:4047)

typedef struct long_shape_type {
 int start_x1, start_y1;
 int start_x2, start_y2;
 int start_x3, start_y3;
 int colour;
 shape_type *prev;
 shape_type *next;
} shape_type;

typedef struct long_line_type {
 int start_x, start_y;
 int end_x, end_y;
 int colour;
 line_type *prev;
 line_type *next;
} line_type;

#include <stdio.h>
#include "graphics_lib.h"
#include <math.h>
#include <conio.h>
/*this is to move the current point up and down to search for data.. this is the linked list bit for finding data*/

//First define "this_line" as a pointer "display_line" = "draw_line"
void display_shape(shape_type *this_shape) 
{

 /* Set the colour */
//to set colour of line. the arrow dereferernces the *
 setcolor(this_shape->colour); 

 /* Double Linked List */
 typedef struct linked_list_parent_for_every_shape {
  int x, y;
  char shape;
  int theta;
  int size;
  int colour;
  shape *prev;
  shape *next;
 } shape 
// this is the real name of the structure

 /*
 * THE MAIN FUNCTION - the programme starts executing here
 */

int main(void)
{

 shape list;

 /* DECLARE VARIABLES */
 int start_x;
 int start_y;
 int end_x;
 int end y;
 int radius;
 shape_type line;
 shape_type circle;
 shape_type triangle;
 shape_type square;

 /* line variables */
 start_x = x;
 start_y = y+(size/2);
 end_x = x;
 end_y = y-(size/2);

// choosing whether to add or remove a drawing
//define a structure as a name, in this case: "shape_type". This needs a variable too


//switch for choosing a new shape and switching between shape conditions
  {
   shape *shape_type; 
case '1':
shape_type = create_shape(); //this function gets info about the position or colour - this set of info = "shape type" - pass this shape type and you can allus pass info
//case '2': //undo
//case '3': //exit
  }

/* 
TITLE SCREEN 
*/

     /* Open a graphics window */
	 initwindow(800, 600);
     printf("SHAPESHIFTER a shape drawing programme by me");
     printf("Press any key to continue");
     getch();

/* 
INSTRUCTION SCREEN
*/

	 printf("1. Use the arrow buttons to choose a shape from the left-hand column and press space bar;\n");
	 printf("2. Use the arrow buttons to choose the size of the shape and press space bar;\n");
	 printf("3. Use the arrow buttons to turn your shape around, and press space bar;\n");
	 printf("4. Use the arrow buttons to choose the colour of your shape and press space bar;\n");
	 printf("5. Move your shape around using all the arrow buttons and press space bar to make a new shape;\n");
	 printf("6. In case you change your mind the computer asks you if you want to rub out your last shape;\n");
	 printf("Press any key to continue");
     getch();

/*
EASEL SCREEN
*/

     /* Size Selection */
     printf("please enter a number for the size of your shape:\n");
     scanf("%d",&size);
	 getch();

     /* Get initial coordinates */
     printf("please enter an x and a y co-ordinate for your shape");
	 getch();
	 printf("x position is: \n");
	 scanf("%d",&x);
	 getch();
	 printf("y position is: \n");
     scanf("%d",&y);
	 getch();

/* 
Drawing the actual shapes 
*/  
	 
     /*line construxion*/
//First define "this_line" as a pointer.
//"display_line" = "draw_line":
//use setcolor(this_line->colour) to set colour of line. the arrow dereferences the *
//"line(this_line->start_x,this_line->start_y,this_line->end_x,this_line->end_y)" sets co-ords to draw line

	 void display_line(line_type *this_line) 
	 {
	 setcolor(this_line->colour); 	 
	 line(this_line->start_x,this_line->start_y,this_line->end_x,this_line->end_y); 
	 }

//(looking at the code above) line is a pointer to a line type
//(looking at the code below) accessing the members of the "structure" 
//(a structure = a collection of different variables like it's 1.2,1.2,1.3 etc but with words
//"line" is the actual name of the variable
//use the (). notation when you haven't got a pointer variable; 
//use the arrow notation when you have got a pointer variable:

	 void get_line(line_type *line_pointer)
	 {
	 scanf("%d", &line_pointer->start_x);
	 scanf("%d", &line_pointer->start_y);
	 scanf("%d", &line_pointer->end_x);
	 scanf("%d", &line_pointer->end_y);
	 scanf("%d", &line_pointer->colour);
	 }

//can't return anything
//I have stored the address &line in the pointer called "line_pointer"; 
//line_pointer contains all the address of the 5 scanf bits above.
//line_pointer is a "postcode" (pointer) that sends data to the "house" (structure) called "line"
//passing by reference

     /* circle construxion */
     radius=size/2;
     circle(x,y,radius);

     /* triangle construxion */
     line_type.start_x = x;
     line_type.start_y = y+(size/2);
     line_type.end_x = x;
     line_type.end_y = y-(size/2);
     //line(x,y-(size/2),x-((sqrt[3])/2),y-(size/2));
     line_type.start_x = x;
     line_type.start_y = y-(size/2);
     line_type.end_x = x-((sqrt[3])/2);
     line_type.end_y = y-(size/2);
     //line(x-((sqrt[3])/2),y-(size/2),x,y+(size/2));
     line_type.start_x = x-((sqrt[3])/2);
     line_type.start_y = y-(size/2);
     line_type.end_x = x;
     line_type.end_y = y+(size/2);
     //line(x+((sqrt[3])/2),y-(size/2),x,y+(size/2));
     line_type.start_x = x+((sqrt[3])/2);
     line_type.start_y = y-(size/2);
     line_type.end_x = x;
     line_type.end_y = y+(size/2);
     //line(x-((sqrt[3])/2),y-(size/2),x+((sqrt[3])/2), y-(size/2));
     line_type.start_x = x-((sqrt[3])/2);
     line_type.start_y = y-(size/2);
     line_type.end_x = x+((sqrt[3])/2);
     line_type.end_y = y-(size/2);

     /* square construxion */
     line(x-(size/2),y+(size/2),x,y+(size/2));
     line(x+(size/2),y+(size/2),x,y+(size/2));
     line(x-(size/2),y+(size/2),x,y-(size/2));
     line(x+(size/2),y+(size/2),x,y-(size/2));

/* 
Displaying the shapes 
*/

//calling the function: "shape" is a local variable; "display_line" is the type of variable to be called
	 display_shape(&triangle);

/*
Rotating the shapes
*/

// p=point; np=new point - changed to "start_x" etc...
   /*
     printf("please enter an angle to rotate your shape by\n);
	 getch();
	 printf("angle:\n);
	 scanf("%d",&theta);
	 getch();
	 printf("press any key to continue\n);
  
     sin_value = sin (theta*PI/180);
     cos_value = cos (theta*PI/180);

     shape_type.x=(((point1.x*cos_value )-(point1.y*sin_value)));
     shape_type.y=(((point1.y*cos_value )+(point1.x*sin_value)));
     shape_type.x=(((point2.x*cos_value )-(point2.y*sin_value)));
     shape_type.y=(((point2.y*cos_value)+(point2.x*sin_value)));
     shape_type.x=(((point3.x*cos_value )-(point3.y*sin_value)));
     shape_type.y =(((point3.y*cos_value)+(point3.x*sin_value )));
     told(point1,point2,point3,0);
     new_triangle(shape_type,3,1);
     copyvalue();
     //[source " http://lavluda.x10hosting.com/download/2d.doc"]
     */
	 scanf("%d",&theta);
     new_x = cos(theta) * x - sin(theta) * y;
     new_y = sin(theta) * x + cos(theta) * y;

getch();
closegraph();
return 0;
}
/*
create_shape()
{
 printf("position")
 scanf

 return shape_type; //return this info to the switch int main body
}
  #15  
Old 15-May-2007, 14:37
promsan promsan is offline
Junior Member
 
Join Date: May 2007
Location: North of the rhubarb triangle, GB
Posts: 53
promsan is on a distinguished road

Re: Linked Lists advice request


So I just ran your code
CPP / C++ / C Code:
typedef struct long_shape_type {
    int start_x1, start_y1;
    int start_x2, start_y2;
    int start_x3, start_y3;
    int colour;
    struct long_shape_type *prev;
    struct long_shape_type *next;
} shape_type;

typedef struct long_line_type {
    int start_x, start_y;
    int end_x, end_y;
    int colour;
    struct long_line_type *prev;
    struct long_line_type *next;
} line_type;

#include <stdio.h>

int main()
{
    shape_type st;
    line_type lt;

    printf("Hi\n");
    return 0;
}

...and got these two errors:
Quote:
--------------------Configuration: shapeshifter - Win32 Debug--------------------
Compiling...
shapeshifter.c
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(25) : warning C4101: 'st' : unreferenced local variable
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(26) : warning C4101: 'lt' : unreferenced local variable

shapeshifter.obj - 0 error(s), 2 warning(s)

I understand what you're doing there... declaring some shapes that'll use these two structures... but I don't see why it's flagging up errors.
  #16  
Old 15-May-2007, 14:45
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,218
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Linked Lists advice request


Quote:
Originally Posted by promsan
So I just ran your code and got these two errors:
They are not errors. They are warnings. I declared the variables but didn't do anything with them (thus the message: "unreferenced variable"). The point was to illustrate how to do the typedefs.

However, to get an absolutely clean compile, try this:
CPP / C++ / C Code:
typedef struct long_shape_type {
    int start_x1, start_y1;
    int start_x2, start_y2;
    int start_x3, start_y3;
    int colour;
    struct long_shape_type *prev;
    struct long_shape_type *next;
} shape_type;

typedef struct long_line_type {
    int start_x, start_y;
    int end_x, end_y;
    int colour;
    struct long_line_type *prev;
    struct long_line_type *next;
} line_type;

#include <stdio.h>

int main()
{
    shape_type st;
    line_type lt;

    printf("sizeof(st) = %d\n", sizeof(st));
    printf("sizeof(lt) = %d\n", sizeof(lt));
    
    return 0;
}


Once you have determined that the typedefs work this way, and once you have an absolutely clean compile (no warnings; no errors), then build up your program by adding a little at a time.

Regards,

Dave
  #17  
Old 15-May-2007, 14:52
promsan promsan is offline
Junior Member
 
Join Date: May 2007
Location: North of the rhubarb triangle, GB
Posts: 53
promsan is on a distinguished road

Re: Linked Lists advice request


not so clean apparently...

Quote:
--------------------Configuration: shapeshifter - Win32 Debug--------------------
Compiling...
shapeshifter.c
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(22) : warning C4101: 'st' : unreferenced local variable
C:\Documents and Settings\...\shapeshifter\shapeshifter\shapeshifte r.c(23) : warning C4101: 'lt' : unreferenced local variable

shapeshifter.obj - 0 error(s), 2 warning(s)

  #18  
Old 15-May-2007, 14:56
promsan promsan is offline
Junior Member
 
Join Date: May 2007
Location: North of the rhubarb triangle, GB
Posts: 53
promsan is on a distinguished road

Re: Linked Lists advice request


This is an entirely different programme, but it's the one I'm using as my basic model to develop from.
It compiles without any errors or warnings on my compiler - does it help?

CPP / C++ / C Code:
/*
 * A start point for the graphics option
 * C Programming laboratory 11
 */

/*
 * Passing by reference
 */
typedef struct long_line_type //this is my structure "long_line_type" and contains the following bits of info:
{
    int start_x, start_y;
    int end_x, end_y;
    int colour;
} line_type; // this is a nickname for the structure "long_line_type"

/*
 * Display a single line
 */
//First define "this_line" as a pointer.
#include "stdio.h"
#include "graphics_lib.h"
void display_line(line_type *this_line) //"display_line" = "draw_line"
{
 /* Open a graphics window */
 initwindow(800, 600);

 /* Set the colour */
 setcolor(this_line->colour); //to set colour of line. the arrow dereferernces the *

 /* Draw the line */
 line(this_line->start_x,this_line->start_y,this_line->end_x,this_line->end_y); //to set a co-ord to draw line
}
//line is a pointer to a line type
void get_line(line_type *line_pointer)
{
 //accessing the members of the "structure" (a collection of differnet variables like it's 1.2,1.2,1.3 etc but with words
//"line" is the actual name of the varaible
 //user the (). notation when you haven't got a pointer variable; use the arrow notation when you have got a pointer variable
scanf("%d", &line_pointer->start_x);
scanf("%d", &line_pointer->start_y);
scanf("%d", &line_pointer->end_x);
scanf("%d", &line_pointer->end_y);
scanf("%d", &line_pointer->colour);
}
//can't return anything

//you have stored the address &line in the pointer called "line_pointer"; line_pointer contains all the address of the 5 scanf bits above.

//line_pointer is a "postcode" (pointer) that sends data to the "house" (structure) called "line"

//passing by reference

 

 

/*
 * Main function
 */

int main(void)
{
 //declare a variable of line_type
 line_type line; //I've now defined summat called "line" that is now a structure of the template called "line_type"
 //call the get_line function
 get_line(&line); //send the function called "get_line" the address of "line".

 //some printfs
 printf("The line goes from %d to %d, and from %d to %d; it's colour is code %d \n",line.start_x, line.start_y, line.end_x, line.end_y, line.colour);

 /*void function{}

 /* Get line information from the user */

 /* Display the lines */

    //calling the function: "line" is a local variable; "display_line" is the type of variable to be called
 display_line(&line);

 getch();

 return 0;
}
  #19  
Old 15-May-2007, 15:07
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,218
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Linked Lists advice request


Quote:
Originally Posted by promsan
not so clean apparently...

Maybe using sizeof() was a bad example, since it is evaluated at compile time. Some compilers create the code first and then look for references later.

Try this to get a clean compile (no warnings whatsoever). Then go forward.

CPP / C++ / C Code:
typedef struct long_shape_type {
    int start_x1, start_y1;
    int start_x2, start_y2;
    int start_x3, start_y3;
    int colour;
    struct long_shape_type *prev;
    struct long_shape_type *next;
} shape_type;

typedef struct long_line_type {
    int start_x, start_y;
    int end_x, end_y;
    int colour;
    struct long_line_type *prev;
    struct long_line_type *next;
} line_type;

#include <stdio.h>

int main()
{
    shape_type st;
    line_type lt;

    st.start_x1 = 12;
    lt.start_x = 34;
    printf("st.start_x1 = %d\n", st.start_x1);
    printf("lt.start_x  = %d\n", lt.start_x);
    
    return 0;
}

Output:
Code:
st.start_x1 = 12 lt.start_x = 34

Regards,

Dave
  #20  
Old 15-May-2007, 15:19
promsan promsan is offline
Junior Member
 
Join Date: May 2007
Location: North of the rhubarb triangle, GB
Posts: 53
promsan is on a distinguished road

Re: Linked Lists advice request


Long time no see!
Quote:
--------------------Configuration: shapeshifter - Win32 Debug--------------------
Compiling...
shapeshifter.c

shapeshifter.obj - 0 error(s), 0 warning(s)

...cheers mate

have one o' these on me; "http://www.e-pint.com/sample.php"

Can I just ask though, is my approach to the shape drawing and rotation sound/sensible at a glance?
(Obviously I'll plug each bit in and see, but I don't know anyone who seems to know)

does this make sense as a way to use the structures as defined above to get data that draws the shapes? (the x, y, and "size" is a user input integer)
CPP / C++ / C Code:
/* triangle construxion */
     line_type.start_x = x;
     line_type.start_y = y+(size/2);
     line_type.end_x = x;
     line_type.end_y = y-(size/2);
     //line(x,y-(size/2),x-((sqrt[3])/2),y-(size/2));
     line_type.start_x = x;
     line_type.start_y = y-(size/2);
     line_type.end_x = x-((sqrt[3])/2);
     line_type.end_y = y-(size/2);
     //line(x-((sqrt[3])/2),y-(size/2),x,y+(size/2));
     line_type.start_x = x-((sqrt[3])/2);
     line_type.start_y = y-(size/2);
     line_type.end_x = x;
     line_type.end_y = y+(size/2);
     //line(x+((sqrt[3])/2),y-(size/2),x,y+(size/2));
     line_type.start_x = x+((sqrt[3])/2);
     line_type.start_y = y-(size/2);
     line_type.end_x = x;
     line_type.end_y = y+(size/2);
     //line(x-((sqrt[3])/2),y-(size/2),x+((sqrt[3])/2), y-(size/2));
     line_type.start_x = x-((sqrt[3])/2);
     line_type.start_y = y-(size/2);
     line_type.end_x = x+((sqrt[3])/2);
     line_type.end_y = y-(size/2);

     /* square construxion */
     line(x-(size/2),y+(size/2),x,y+(size/2));
     line(x+(size/2),y+(size/2),x,y+(size/2));
     line(x-(size/2),y+(size/2),x,y-(size/2));
     line(x+(size/2),y+(size/2),x,y-(size/2));

and one of the rotation approaches is supposed to be along the same lines, but I've commented it out in favour of what looks like a simpler one
CPP / C++ / C Code:
/*
Rotating the shapes
*/

// p=point; np=new point - changed to "start_x" etc...
   /*
     printf("please enter an angle to rotate your shape by\n);
	 getch();
	 printf("angle:\n);
	 scanf("%d",&theta);
	 getch();
	 printf("press any key to continue\n);
  
     sin_value = sin (theta*PI/180);
     cos_value = cos (theta*PI/180);

     shape_type.x=(((point1.x*cos_value )-(point1.y*sin_value)));
     shape_type.y=(((point1.y*cos_value )+(point1.x*sin_value)));
     shape_type.x=(((point2.x*cos_value )-(point2.y*sin_value)));
     shape_type.y=(((point2.y*cos_value)+(point2.x*sin_value)));
     shape_type.x=(((point3.x*cos_value )-(point3.y*sin_value)));
     shape_type.y =(((point3.y*cos_value)+(point3.x*sin_value )));
     told(point1,point2,point3,0);
     new_triangle(shape_type,3,1);
     copyvalue();
     //[source " http://lavluda.x10hosting.com/download/2d.doc"]
     */
	 scanf("%d",&theta);
     new_x = cos(theta) * x - sin(theta) * y;
     new_y = sin(theta) * x + cos(theta) * y;
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
triangle (polygon), drawing, sizing, and rotation programme using linked lists... promsan C Programming Language 12 14-May-2007 15:03
Doubly linked lists in C++ sweeeeeeetlipss C++ Forum 1 24-Oct-2006 00:27
[Include] Doubly-linked List dsmith C Programming Language 6 14-Apr-2006 14:12
help on linked lists any1????? nick4 C Programming Language 1 17-May-2004 10:32
linked lists, newbie needs help moltarim C Programming Language 4 06-May-2004 12:32

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:10.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.