Question "Four point" images

gullible77

New member
Joined
May 27, 2008
Messages
4
Programming Experience
3-5
In VB, you only seem to be able to draw an image with three points specified.
Is there anyway you can edit the fourth point, without the image being drawn as a parallelogram?
Hopefully this makes sense to someone.

Mick
 
If you need to tell the fourth point of a rectangle in a 2d space from its first 3 points, I think you need one more info. You need to know which point you already know is not connected (and is opposite) to the fourth one.

We will call the opposite point pt1, and the other two pt2 and pt3.

From this, use this :

VB.NET:
dim deltaX as integer = pt2.X - pt1.X
dim deltaY as integer = pt2.Y - pt1.Y
dim pt4 as new Point(pt3.X + deltaX, pt3.Y + deltaY)

pt4 should be your last point. Now, I did not presume you worked along any axis so this will work with rectangles that cannot be represented by an Rectangle object too!

If you don't already know which point is opposite to the one you are looking for, you may try to calculate the angles formed by a triangle joining the three points and looking for one with a value of 90 degrees (keep a certain approximation error margin by simply taking the one that's closest to 90). You must be certain it is possible to create a rectangle with those.

Btw, if the sum of the three angles is not 180, then you messed up calculating the angles ;) . I can't remember the name of that rule... :confused:

Also, if you only have 3 points that can make a rectangle, no matter where you place the fourth one, you cannot make a parallelogram (unless you tell me a rectangle is a parallelogram), only a trapezoid :p
 
In VB, you only seem to be able to draw an image with three points specified.
Is there anyway you can edit the fourth point, without the image being drawn as a parallelogram?
I have not found functionality for perspective warping images. For example GraphicsPath has Warp method but it only applies to the path shapes, not the fill. If you fill it with a TextureBrush it will only do variations of tile and not stretch it.
 
Back
Top