News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Homography

Started by JuneTheSecond, June 08, 2017, 01:45:05 AM

0 Members and 1 Guest are viewing this topic.

JuneTheSecond

The other day we have given a question about perspective text at
http://visguy.com/vgforum/index.php?topic=7901.msg33900#msg33900 .
This is also a theme about homography.
There are many documents about homography in the web.
Among them I think the easiest one may be this document at
https://www.codeproject.com/Articles/674433/Perspective-Projection-of-a-Rectangle-Homography .

Referring to this document I tried to make a VBA macro to calculate the location of a point after transformation.
I think it works well, but I cannot yet remind any good idea for user interface for homography, or for perspective text.

Any idea?

`Option ExplicitSub test_Xout_Yout()    Dim shp As Visio.Shape    Dim Xin As Double, Yin As Double        Set shp = ActiveWindow.Selection.PrimaryItem        Xin = shp.Cells("Width").Result(visMillimeters) * 0.5    Yin = shp.Cells("Height").Result(visMillimeters) * 0.5        Set shp = ActiveWindow.Selection.PrimaryItem        Debug.Print Xout(shp, Xin, Yin), Yout(shp, Xin, Yin)End SubFunction Xout(shp As Visio.Shape, Xin As Double, Yin As Double) As Double    Xout = (A(shp) * u(shp, Xin) + B(shp) * v(shp, Yin)) / (G(shp) * u(shp, Xin) + H(shp) * v(shp, Yin) + 1) + X0(shp)End FunctionFunction Yout(shp As Visio.Shape, Xin As Double, Yin As Double) As Double    Yout = (D(shp) * u(shp, Xin) + E(shp) * v(shp, Yin)) / (G(shp) * u(shp, Xin) + H(shp) * v(shp, Yin) + 1) + Y0(shp)End FunctionFunction X0(shp As Visio.Shape) As Double    X0 = shp.Cells("Geometry1.X1").Result(visMillimeters)End FunctionFunction X1(shp As Visio.Shape) As Double    X1 = shp.Cells("Geometry1.X2").Result(visMillimeters)End FunctionFunction X2(shp As Visio.Shape) As Double    X2 = shp.Cells("Geometry1.X3").Result(visMillimeters)End FunctionFunction X3(shp As Visio.Shape) As Double    X3 = shp.Cells("Geometry1.X4").Result(visMillimeters)End FunctionFunction Y0(shp As Visio.Shape) As Double    Y0 = shp.Cells("Geometry1.Y1").Result(visMillimeters)End FunctionFunction Y1(shp As Visio.Shape) As Double    Y1 = shp.Cells("Geometry1.Y2").Result(visMillimeters)End FunctionFunction Y2(shp As Visio.Shape) As Double    Y2 = shp.Cells("Geometry1.Y3").Result(visMillimeters)End FunctionFunction Y3(shp As Visio.Shape) As Double    Y3 = shp.Cells("Geometry1.Y4").Result(visMillimeters)End FunctionFunction X00(shp As Visio.Shape) As Double    X00 = X0(shp) - X0(shp)End FunctionFunction X01(shp As Visio.Shape) As Double    X01 = X1(shp) - X0(shp)End FunctionFunction X02(shp As Visio.Shape) As Double    X02 = X2(shp) - X0(shp)End FunctionFunction X03(shp As Visio.Shape) As Double    X03 = X3(shp) - X0(shp)End FunctionFunction Y00(shp As Visio.Shape) As Double    Y00 = Y0(shp) - Y0(shp)End FunctionFunction Y01(shp As Visio.Shape) As Double    Y01 = Y1(shp) - Y0(shp)End FunctionFunction Y02(shp As Visio.Shape) As Double    Y02 = Y2(shp) - Y0(shp)End FunctionFunction Y03(shp As Visio.Shape) As Double    Y03 = Y3(shp) - Y0(shp)End FunctionFunction X12(shp As Visio.Shape) As Double    X12 = X02(shp) - X01(shp)End FunctionFunction Y12(shp As Visio.Shape) As Double    Y12 = Y2(shp) - Y1(shp)End FunctionFunction X32(shp As Visio.Shape) As Double    X32 = X02(shp) - X03(shp)End FunctionFunction Y32(shp As Visio.Shape) As Double    Y32 = Y02(shp) - Y03(shp)End FunctionFunction Gdash(shp As Visio.Shape) As Double    Gdash = (X02(shp) * Y32(shp) - Y02(shp) * X32(shp)) / (X12(shp) * Y32(shp) - Y12(shp) * X32(shp))End FunctionFunction Hdash(shp As Visio.Shape) As Double    Hdash = (X12(shp) * Y02(shp) - Y12(shp) * X02(shp)) / (X12(shp) * Y32(shp) - Y12(shp) * X32(shp))End FunctionFunction A(shp As Visio.Shape) As Double    A = Gdash(shp) * X01(shp)End FunctionFunction D(shp As Visio.Shape) As Double    D = Gdash(shp) * Y01(shp)End FunctionFunction B(shp As Visio.Shape) As Double    B = Hdash(shp) * X03(shp)End FunctionFunction E(shp As Visio.Shape) As Double    E = Hdash(shp) * Y03(shp)End FunctionFunction G(shp As Visio.Shape) As Double    G = Gdash(shp) - 1End FunctionFunction H(shp As Visio.Shape) As Double    H = Hdash(shp) - 1End FunctionFunction u(shp As Visio.Shape, Xin As Double)    u = Xin / shp.Cells("Width").Result(visMillimeters)End FunctionFunction v(shp As Visio.Shape, Yin As Double)    v = Yin / shp.Cells("Height").Result(visMillimeters)End Function`
Best Regards,

Junichi Yoda
http://june.minibird.jp/

Yacine

It's about correct isometrics, in case someone thinks something else.
Yacine

wapperdude

#2
Quote from: Yacine on June 08, 2017, 06:01:53 PM

😱  😕  😁
Visio 2019 Pro

vojo

June...are you creating iso via 2D + control points (like your other shapes)...
or
...using 2013 3D (I don't know to get control points to translate into 3D...standard 2013 transforms don't do it.)

If you are transforming, why not do something like this (fine the middle diagonal pair of control pts...do it again for single pt)
Sort of the theory behind Bezier curves.

user.centerx1 = (controls.row_3.x - controls.row_1.x)/2
same for centery1
user.centerx2 = (controls.row_4.x - controls.row_2.x)/2
same for center y2

more if more control points

user.centerxx = (centerx2-centerx1)/2
user.centeryy = (centery2-centery1)/2

connector.x1 = user.centerxx....user.centeryy

Would that give the center to any regular convex shape (and some concave shapes)?

Yacine

#4
Quote from: wapperdude on June 09, 2017, 01:17:35 AM

😱  😕  😁
You - my buddy - followed me ...
Yacine

wapperdude

By cheating...well, sort of.  I have a Kindle Fire and these, plus many more, came with it. Never searched, but there must be a slew of emoticons on the internet.

If you've noticed an increase in errors, well, touch screens and I have this raging disagreement...😠  😨
Visio 2019 Pro

JuneTheSecond

And then I tried a trial macro to make perspective view.
Here is a short video, please enjoy.
https://youtu.be/UyCPt1GggVg
Best Regards,

Junichi Yoda
http://june.minibird.jp/

wapperdude

Junichi-san,

That is very nice.  The macro runs so fast that it's almost magic.  This is most impressive development.

Well done!

Wapperdude
Visio 2019 Pro

JuneTheSecond

Thank you, Wapperdude!

Here is another trial using character shape.
And a short video, please enjoy.
https://youtu.be/gcRpLcjqrTE

But I have not yet any good user interface.
Best Regards,

Junichi Yoda
http://june.minibird.jp/

vojo

in case you were seriously asking

;-)  = semi colon dash close parenthesis
:-) = colon dash close parenthesis
:-0 = colon dash number 0 (or letter o)

wapperdude

#10
. Not sure that's the interface JuneTheSecond meant...could be...

Now, for my guess  ...the interface refers to his control shape.  Here are some ideas....
1) use double click to run the macro
2)  add control point at mid-line to drag line without changing angle
3) maybe some sort of non-modal message box that asks user to select the target shape to be mapped into the "transform" shape.

Just some thoughts.
Wapperdude
Visio 2019 Pro

JuneTheSecond

#11
Thank you guys.
I am sorry I am not clear.
Yes, I am not clear.
I think any user can not use my macro very easy.
I don't think any user don't like to use it to make
the perspective text.
I also feel very hard to prepare all the shapes
to run the macro.

How would you think to use list container
in place of current group?
Best Regards,

Junichi Yoda
http://june.minibird.jp/

wapperdude

I don't have much time this weekend.  Have only watched the videos so far and not tried the code.

Regarding containers or not...Since I stopped upgrading at V2007, containers of no use.  But, containers is the direction new releases use.

Best,
Wapperdude
Visio 2019 Pro

JuneTheSecond

Thank you so much.
Then I tried a List Container.
User interface is now much better.
Here is a short video, please enjoy.
https://youtu.be/Q-wUc2Do_kY
Best Regards,

Junichi Yoda
http://june.minibird.jp/

wapperdude

Yes.  That seems much better.

Very nice.  Quite simple.

Wapperdude
Visio 2019 Pro

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 423 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1272KB.