home *** CD-ROM | disk | FTP | other *** search
-
- ·C·O·D·E·X· ·D·E·S·I·G·N· ·S·O·F·T·W·A·R·E·
- presents:
-
- Create Sinus Values V1.00
- - CSinVals -
-
- programmed 15.9.1994 by Hans Bühler
- (c)1994 Codex Design Software (Amiga)
- all rights reserved
-
- -I- Intro
-
- I.1. Idea
-
- This program is dedicated to those who want easily FAST calculate sinus
- or cosinus values from a specific angle. It bases on an idea mainly used
- in assembly programms, I assume:
- One stores each sinus value from 0° to 360° degrees (or in any range he
- needs) in a WORD or LONGWORD area, multiplied by a secific value,in most
- cases you would choose a power of 2, maybe 256 = 2^8.
- Then, let's say, you want to calculate a rotation of P(Px|Py) by an an-
- gel of 75°, you just calculate:
-
- NewPx = (Px * Sin[75]) / 256 == (px * Sin[75]) >> 8;
- NewPy = (Py * Cos[75]) / 256 == (px * Cos[75]) >> 8 == Py * Sin[75+90];
-
- whereby Sin[] is a pointer to an array of some data, might be calculated
- using CSinVals V1+.
- This way you trick out the math.lib or the system.
-
- I.2. The trick
-
- This program, CSinVals, is needed to create these sinus data values,and
- it offers much options allowing the user to modify these data the way he
- wants to.
-
- I.3. System requirements
-
- CSinVals V1+ will work on every Amiga equipped with Kick2.0 or higher.
-
-
-
- -II- Program
-
- II.1. Parameters
-
- CSinVals is a very ;) simple commandline command,offering the following
- options (AmigaDOS keywords parsed by ReadArgs()).
- Due the source is added,one may change the code in order to run it with
- Kick1.2 or anything.
-
- This is the commandline:
-
- CSinVals C-FILE/A,
- LABEL/K,COSLAB/K,
- START/K/N,COUNT/K/N,STEP/K/N,
- MULTI/K/N,ADD/K/N,
- CHAR/S,SHORT/S,LONGINT/S,
- OVERWRITE/S
-
- Introduction to the parameters:
-
- C-FILE/A is the only really required arument.It defines the destination
- file used to store the ASCII C-Language output in.
- CSinVals V1.00 WON'T extend the file's name by '.c' ; do it
- yourself !
- If you don't use option OVERWRITE additionally, you will be
- requested whether to delete an already existing file,always.
-
- LABEL=<Label> says CSinVals to use the string <Label> as label for the
- Sinus-Array. Defaults to [SinValues].
- COSLAB=<Label> says CSinVals to additionally create a label for the Co-
- sinus datas (the number of values , set by COUNT will auto-
- matically rised by 90/STEP to gurantee that Cos[Angel] will
- work).
- NOTE: I assume, that the compiler you are going to use will
- put data arrays that are *listened* behind each other
- will be compiled laying behind each other.
- If you are not sure,I advise you NOT to use the opt.,
- but rise COUNT by '90/STEP' and use this preprocessor
- command:
- #define CosValues(ANGEL) SinValues[(90/STEP)+ANGEL]
- This will always work correcly.
- Default is NO label.
-
- START=<start_with_angel> defines the first angel to get a sinus()-value
- from. The angel will NOT be taken as radians.
- Defaults to [0].
- COUNT=<number_of_values> says CSinVal how much values you need.Remember
- that using 'COSLAB=' would increase the number of values by
- 90/STEP.
- Defaults to [360/STEP].
- STEP=<difference_between_to_angels> says CSinVal what it has to add to
- the previous angel . In fact , it's how fine you need your
- values.
- Defaults to minimum [1].
-
- MULTI=<mutliply_each_value_by> makes CSinVal multiplying each sin-value
- by this number. It might be useful to have powers of 2 for
- this number : Thus you can easily shift right the result of
- any calculations by the power itself.
- Let's say you have MULTI=128 and you want to calculate
- NewVal = 100 * sin(75), do:
- NewVal = (100 * SinDat[75]) >> 7;
- ...and everything is fine.
- Default is [256=2^8].
- ADD=<add_to_each_value> forces CSinVal to add the number specified here
- to each value (after MULTIplication !).
- Use this e.g. to fix values beeing negative.
- Default is [0].
-
- CHAR (switchable) forces to store all data in an char array.
- NOTE: CSinVal will not check whether any value exceeds the
- limits of the data class !!!!!!!!!!!
- SHORT (switchable) same for word array.
- LONGINT (switchable) same for long integer data class.
- Defaults to [SHORT].
-
- OVERWRITE (switchable) disables requesting for file already existing.
- Be careful !
- You might destroy data you will never get back !
- Defaults is to get confirmation from the user first.
-
- II.2. A little test
-
- Let's say you need the Sinus()- and Cosinus()-values for an amplifier ,
- minimum angel of 20° , maximum of 160° , and you are sure you only need
- each 2nd value, that means two inputs differ by not less than 2. You do
- not want to much trouble, so you want to multiply each value by 512=2^9.
- You want to save these data in file called 'CoSinus.c' , offering two
- BYTE labels 'CosData[]' and 'SinData[]' to the linker.
- Moreover, because you want to generate these data by your 'smakefile' ,
- you neither need output nor any confirmation whether to overwrite an old
- file (you are sure you know where you put the data):
- In this case, COUNT isused to be COUNT=(160-20)/2=70
-
- CSinVal >NIL: CoSinus.c START=20 COUNT=70 STEP=2 MULTI=512
- LABEL=SinData COSLABEL=SinData
- CHAR OVERWRITE
-
- Now get a new amplifier's position offset (a is the len of the vector):
- (remember 'extern UBYTE SinDat[],CosDat[];')
-
- / Ax(Alpha) \ / (a * SinDat[Alpha >> 1]) >> 9) \
- A(Alpha) = | | = | |
- \ Ay(Alpha) / \ (a * CosDat[Alpha >> 1]) >> 9) /
-
-
-
- -III- Postscriptum
-
- III.1. Copyrights
-
- This program, its source and this little text is copyrighted by the
- author. He reserves all rights for himself, while allowing everybody
- to copy this program for his own private or commercial use.
- It is not permitted to change anything within the program, the source
- or the documentation. It is my work !
- Any responsibilty for damage to hard- or software inflicted by
- the use or misuse of this program is given to the user.
- I can't and won't ever gurantee anything concerning the effects
- caused by this program !
-
- III.2. History
-
- 15.9.1994 initial version. Supports CLI argument parsing; no bugs found.
-
- III.3. Future
-
- - Generate assembly source, too.
-
- III.4. Additionals
-
- Codex Design Software, Amiga section
- Hans Bühler
- Kirchstr.22, 10557 Berlin 21
- FRGermany
- call +49(0)30 393 38 14 or +49(0)30 392 79 42
-
-
- BYE.
-
-