70002510 Mapping vdImage with world coordinate system

Article 70002510
Type Wish
Product Engine
Version 1005
Date Added 4/14/2024 12:00:00 AM
Fixed 11.1.4.0 (4/14/2024 12:00:00 AM)
Submitted by Eric Guilhaurre

Summary

Mapping vdImage with world coordinate system when there is Vertical Deviation from the sandard default 90 degrees relative to horizontal rotation

Solution

In version 11.1.4 a new property VerticalDeviation of vdImage was added
Get/Set the vertical deviation angle in radians of the image
Represents the result of the horizontal angle in the Width direction minus the vertical angle in the Height direction minus 90 degrees


A new utility method SetOrientation was also added
void SetOrientation(gPoint origin, Vector xdir, Vector ydir)
Select the orientation that maps the selected image pixels to the world Coordinate System
This method uses the input parameters and calculates the appropriate Width Height Rotation InsertionPoint KeepAspect ExtrusionVector and VerticalDeviation
origin: the lowerleft corner in the world cs
xdir: a normal that defines the rotation and the width in drawing units
ydir: a nornal that defines the height and its direction


Example

        // Suppose we have import an image test.jpg the following by a test.jgw georeferenced file that used to map the raster image to World Coordinate System
        // test.jgw file has the following contents:
        // 
        // 0.10183777847843305 (a: increment of x-coordinate per pixel)
        // 0.00067825122389361875 (b: rotation in radians in x-width direction)
        // 0.0009059301761081954 (c: rotation  in radians in y-height direction)
        // -0.10089738316603658 (d: increment of y-coordinate per pixel)
        // 1760.254362179789 (e: x-coordinate of the pixel at top left of the image)
        // 6166.2682902796987 (f: y-coordinate of the pixel at top left of the image)
        // 
        
        double a =  0.10183777847843305;
        double b =  0.00067825122389361875;
        double c =  0.0009059301761081954;
        double d =  -0.10089738316603658;
        double e =  1760.254362179789;
        double f =  6166.2682902796987;
        vdImageDef idef = doc.Images.Add("test.jpg");
        vdImage image = new vdImage(doc);
        image.ImageDefinition = idef;
        Vector xdir = new Vector(a, b, 0) * image.ImageDefinition.Width;
        Vector ydir = new Vector(c, d, 0) * image.ImageDefinition.Height;
        gPoint origin = new gPoint(e, f) + ydir;
        image.SetOrientation(origin, xdir, ydir* -1);
        doc.Model.Entities.AddItem(image);
        doc.Redraw(false);
        

Send comments on this topic.