I originally was going to make a program that could draw rotated 3-D prisms, but it turns out that somebody already made that, so because I didn't want to waste the code I already have, I turned it into something that can draw any polygon rotated at any angle. It's for the TI-89/Ti-92+/Voyage 200, and was written in C.
I didn't do much testing with it, but it should work. The only thing you have to worry about is you need to make sure you use it correctly, or else it can crash your calculator. Here is how to use it:
prism(row,column,angleInDegrees,mode,point1x,point1y,point2x,point2y,...)
It definitely should be fast enough. All of the parameters are integers. Here are the different mode settings:
0 - reverse
1 - normal
2 - xor
4 - replace
5 - or
To download this, see the attachment.
Firefox is rejecting the attachment.
Right Click -> Save Link As... might work.
Well... No. The link, as shown in the lower left by Firefox, is really some PHP thing. In other words, I'll save something with a php extension.
Does this allow rotating the polygon around a given point? Is that what the first two arguments indicate? If so, why are the first two arguments rows and columns and the rest of them coordinate pairs? In addition, you ARE using a lookup table, right? Have you made sure that the lookup table is not using too much/too little precision? Have you considered making the lookup table (if any) into a separate DLL/file? (If it is a DLL, you could implement a trigonometry API that can do trigonometric functions while being aware of the identities, without making the programmer do this manually.)
- Does this allow rotating the polygon around a given point? If so, why are the first two arguments rows and columns and the rest of them coordinate pairs?
> This doesn't really allow rotating the polygon around a given point The row and column are the "base" points for the "offset" points. For example, if the row were 2 and the column were 7, and one of the points were 13,12 (row, column), then the ACTUAL location on the screen where that point would be would be 13+2,12+7, or 15,19.
- In addition, you ARE using a lookup table, right? Have you made sure that the lookup table is not using too much/too little precision?
> Yeah, I'm using a look-up table of chars in degrees for the sine, which are 64*there values (so I don't have to user larger floating point values. Why times 64, you ask? Well, besides to make them able to fit in chars, (128 would be slightly too much, and I felt this would be the fastest alternative), 64 is also easy to divide by (shift the bits to the right 6 times), and I don't lose too much precision, not that it really matters anyway, considering the calculator's resolution. (Oh, and I don't need another look-up table for the cosine because as you probably know, the cosine can easily be expressed in terms of the sine).
- Have you considered making the lookup table (if any) into a separate DLL/file? (If it is a DLL, you could implement a trigonometry API that can do trigonometric functions while being aware of the identities, without making the programmer do this manually.)
> While this might be handy, there are a few problems with this:
My program is supposed to run fast and using a DLL would probably slow it down (although only slightly). DLLs are usually good when two or more programs will be using them, or if the program is too large to fit it; my program was definitely not too large, and I wasn't planning on making any programs anytime soon that would require pre-calculated trigonometric values, and I doubt other people would use my API. Actually...a DLL containing things like pre-calculated trigonometric values might not be such a bad idea, but still probably wouldn't be ideal in this case, because I was trying to keep this pretty fast (this was originally supposed to render 3-D prisms, so speed was definitely going to be important, and I kind of kept that attitude, even though I never got around to making it render 3-D prisms, only 2-D polygons, because somebody already made a program that did that).
prism(row,column,angleInDegrees,mode,point1x,point1y,point2x,point2y,...)
Um, so are all of the coordinates in (x,y) format as the last part of that would indicate or in (row,column) format? Because those are two totally different things...
I guess I should have made the first two parameters be (column, row). And where it says (x,y), it actually is (row,column). Oh, well.