hi Chris, all


This function rotate a region with the angel v, around the centroide of the
object. Note that the function only rotates a simpel region with one
polygon

NB - there was an error in my first mail

Function RotateObj(byval o as object, byval v as float )as object
    dim i, N as Integer,
        NewObj as object,
        NewX, NewY, X, Y, cx, cy, AngelRad as float

    RotateObj = o
    AngelRad  = v * DEG_2_RAD
    if objectInfo(o, obj_info_type) = obj_type_region then
       N = ObjectInfo(o, OBJ_INFO_NPNTS)
       Create Region into Variable NewObj 0
       cx = centroidx(o)
       cy = centroidy(o)
       For i = 1 to N
           X = ObjectNodeX(o, 1, i) - cx
           Y = ObjectNodeY(o, 1, i) - cy
           NewX = cx + ((X * cos(AngelRad)) - (y * sin(AngelRad)))
           NewY = cy + ((X * Sin(AngelRad)) + (y * Cos(AngelRad)))
           Alter Object NewObj  Node Add ( Newx, Newy )
       Next
       Alter Object NewObj Geography OBJ_GEO_CENTROID, CreatePoint(cX, cY)
       RotateObj = NewObj
    else
       print "object is not a region"
    end if
end function


Med venlig hilsen
Peter Laulund

*************************************************************
Kort & Matrikelstyrelsen  ·  www.kms.dk
National Survey and Cadastre - Denmark
Rentemestervej 8  ·  DK 2400 København NV
E-mail:  [EMAIL PROTECTED]  ·  Home: [EMAIL PROTECTED]
Phone: +45 3587 5050  ·  Direct: +45 3587 5173

*************************************************************







"galmala" <[EMAIL PROTECTED]> - 2000 09 06 01:13:04

Til:    [EMAIL PROTECTED]
cc:      (bcc: Peter Laulund/MI/KMS)
Vedrørende:    MI Mapbasic - object rotation



Hey there guys,


I have written a simple mapbasic script/routine that plots various
rectangles from data on a table. What I would like to do next is be able to
rotate these objects .... I know that you can rotate symbols, but is there
any statement / function to rotate ojects (rectangles created from Create
Rect)???

Thanks in advance,

Chris

Hey there guys,
 
 
I have written a simple mapbasic script/routine that plots various rectangles from data on a table. What I would like to do next is be able to rotate these objects .... I know that you can rotate symbols, but is there any statement / function to rotate ojects (rectangles created from Create Rect)???
 
Thanks in advance,
 
Chris

Reply via email to