SRL Archive - Outdated Tutorials

~ FindDTMRotated ~


Abyssal

2007-05-18 23:56:31

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Welcome to my FindDTMRotated tutorial!
Let's start off by downloading the attachment picture.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

Let's start off with making a DTM, if you are doing this tutorial I assume you know how to do that. Here is what I made:


DTMFromString('78DA63D462606090654005424B18588114231' +
'0FF0702463320431855C9A9FB7FE06A4080510753CDD97BFF51D5' +
'A862AA61903F8EAA460A48C8A02AD97FF01CAA1A75903E5435CC6' +
'23331DDA385AAE6FCD10BA86A8C818402AA1A4B9FA3286A00FE60' +
'13FA');

Create a variable, "dtmComp" and have it be that dtm up there. Also declare x and y as integers. Don't forget to declare a as extended for later.

Good, now the parameters for FindDTMRotated are the following:

FindDTMRotated(DTM, x, y, x1, y1, x2, y2: Integer; StartAngle, EndAngle, AngleStep: Extended; var Angle: Extended): Boolean;

So open up that image in paint, and then select the image.
I will explain the following params:

FindDTMRotated(dtmComp, x, y, 0, 0, 100, 100, 0, 360, 0.01, a);

That searches in a 100x100 box, searching 360 degrees, going 0.01 angles at a time. The angle it finds it at is stored in the variable "a".

Use this code:

var
dtmComp, x, y: Integer;
a: Extended;

begin
dtmComp:= DTMFromString('78DA63D462606090654005424B18588114231' +
'0FF0702463320431855C9A9FB7FE06A4080510753CDD97BFF51D5' +
'A862AA61903F8EAA460A48C8A02AD97FF01CAA1A75903E5435CC6' +
'23331DDA385AAE6FCD10BA86A8C818402AA1A4B9FA3286A00FE60' +
'13FA');
FindDTMRotated(dtmComp, x, y, 0, 0, 100, 100, 0, 360, 0.01, a);
MoveMouse(x, y);
end.

Most of the code is self-explanatory.

Now, go into paint, and go to the image menu, then flip/rotate menu. Rotate it by either 90, 180, or 270 degrees.


Run the script, and see if it moves the mouse.
I hope this tutorial has helped you understand more about FindDTMRotated.
If you have any questions, please ask here.

PwNZoRNooB

2007-05-19 02:08:07

I've used this before but 1 question, how can I use the
Var: Angle : extended
That you get there?

Markus

2007-05-19 04:40:21

Nice tut, but the angle isn't in degrees, but in radians.
360° = 2pi. So it should be

FindDTMRotated(dtmComp, x, y, 0, 0, 100, 100, 0, 2*pi, 0.01, a);

PwNZoRNooB

2007-05-19 08:34:56

Id like to ask help, I'll ask here because here's the tut :)

This doesn't work for me

if(FindDTMRotated(TreeDTM, MouseCoordX, MouseCoordY, 584, 3, 734, 162, 0, 360, 2, a))

It says type mismatch on the anglestep (2), I didn't get it why it does it :/ :(

~alex~

2007-05-19 09:34:51

Dtmrotated is just a more simple way of using this, less arguments and if you don't really know what your doing with the step etc. its your best bet.

Abyssal

2007-05-19 09:51:17

Pwnzor, my guess is that the angle has to be 2.0?

I know I get an error if my angle is .01 without the leading zero. Try that, and post back. Glad to hear the tut went well.

PwNZoRNooB

2007-05-19 09:57:39

Nope, I already tried that, I also tried 1 , 1.0 & 0.01 for I still get the Type Mismatch there :(

I'm using Scar 2.03 and SRl 3.6 but this worked for me a while ago :/
Trying to solve it out.

Edit: This is really weird, this is in my other script that I never finished.
if(FindDTMRotated(TreeOnMM, MouseCoordX, MouseCoordY, 551, 0, 751, 163, 0, 360, 2, Angle))
And the script compiles and starts without errors … ?
Very odd…

Edit: 2 Okay… Fixed it

if(FindDTMRotated(TreeDTM, MouseCoordX, MouseCoordY, 584, 3, 734, 162, 0, 360, 2, a))
That doesn't work but this does
if(FindDTMRotated(TreeDTM, MouseCoordX, MouseCoordY, 551, 0, 751, 163, 0, 360, 2, Angle))
Don't know what was it prob, but it's now fixed :p

bullzeye95

2007-05-19 10:50:29

Yeah if you want to search in 360 degrees, make the StartAngle 0.0, and make EndAngle Pi * 2. ;)