gmggroup / omf-python

Python library for working with OMF files
MIT License
79 stars 20 forks source link

Improve description and update code snippet in ImageTexture docs #33

Closed banesullivan closed 5 years ago

banesullivan commented 5 years ago

The code docs for the ImageTexture are a bit vague to me after loading the example data...

How should we use the axis_u, axis_v and origin properties? The example in the docs makes it seem like the image plane will be aligned with the surface extents but the topography example in the test file has a texture where the origin (Vector3([443200., 491750., 0.])) is out of the bounds ((443941, 447059, 491941, 495059, 2383, 3555)) of the topography surface. In order to properly use that texture, I would need to know the full extents of the texture along its axis_u and axis_v directions.

Am I missing something here?

Or should I just extend a plane out from the origin in the axis_u and axis_v directions all the way to the max extent of the surface?

banesullivan commented 5 years ago

I may have figured this out... Do we create a plane from three points by extending two points from the origin by the axis_u and axis_v vectors such that you have three points:

At least this creates a mapping that looks pretty good to me.

fwkoch commented 5 years ago

Hey @banesullivan - thanks for this. Sounds like your conclusion is correct. The axis_* values are both relative to the origin. Given a rectangular PNG image, origin is the bottom left, origin + axis_u is the bottom right, and origin + axis_v is the top left. This allows you to rotate and skew your image. These values are totally independent of the corresponding Surface; there's nothing requiring the image to actually align with the Surface...

Also, thanks for pointing out shortcomings in the docs; not only is the described behaviour vague, even the code snippet is out of date (with O, U, V, rather than origin, etc...). I'll update this issue to reflect that these need to be addressed.

banesullivan commented 5 years ago

Thanks, @fwkoch!

adasys commented 5 years ago

This implies that all planes are horizontal??

Should there be an additional rotation matrix added to the spec. so that the plan can be oriented in space and potentially scaled?

Andrew

On Tue, 22 Jan 2019 at 14:28, Franklin Koch notifications@github.com wrote:

Hey @banesullivan https://github.com/banesullivan - thanks for this. Sounds like your conclusion is correct. The axis_* values are both relative to the origin. Given a rectangular PNG image, origin is the bottom left, origin + axis_u is the bottom right, and origin + axis_v is the top left. This allows you to rotate and skew your image. These values are totally independent of the corresponding Surface; there's nothing requiring the image to actually align with the Surface...

Also, thanks for pointing out shortcomings in the docs; not only is the described behaviour vague, even the code snippet is out of date (with O, U, V, rather than origin, etc...). I'll update this issue to reflect that these need to be addressed.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gmggroup/omf/issues/33#issuecomment-456530812, or mute the thread https://github.com/notifications/unsubscribe-auth/AQR4Ck7jrQK0zQkOI01AElq59OPmmrYtks5vF2ZLgaJpZM4aNA4T .

banesullivan commented 5 years ago

I'm thinking... The plane does not have to be horizontal. If you build out the other two points of the plane from the origin by the axis_* vectors then the plane can have any arbitrary orientation defined by those three properties.

Note that the axis_* have an X, Y, and Z component

fwkoch commented 5 years ago

Thanks, yeah, exactly. For example:

ImageTexture(
    ...
    axis_u=[1., 0., 0.],
    axis_v=[0., 1., 0.],
)

would be horizontal, but

ImageTexture(
    ...
    axis_u=[1., 0., 0.],
    axis_v=[0., 0., 1.],
)

would be vertical. And something like

ImageTexture(
    ...
    axis_u=[0.5, 0.5, 0.],
    axis_v=[-0.5, 0., 0.5],
)

would be at an angle and a bit askew.

Possibly, however, there is an alternative way to to describe the orientation of a plane that is more intuitive to users of this library?

banesullivan commented 5 years ago

Possibly, however, there is an alternative way to to describe the orientation of a plane that is more intuitive to users of this library?

I think the three-point method is the best definition of a plane. I just didn't realize the axis_* properties defined the points relative to the origin.

adasys commented 5 years ago

Apologies I have no idea why I was thinking that the vectors were in 2D.

On Tue, 22 Jan 2019 at 15:02, Franklin Koch notifications@github.com wrote:

Thanks, yeah, exactly. For example:

ImageTexture( ... axis_u=[1., 0., 0.], axis_v=[0., 1., 0.], )

would be horizontal, but

ImageTexture( ... axis_u=[1., 0., 0.], axis_v=[0., 0., 1.], )

would be vertical. And something like

ImageTexture( ... axis_u=[0.5, 0.5, 0.], axis_v=[-0.5, 0., 0.5], )

would be at an angle and a bit askew.

Possibly, however, there is an alternative way to to describe the orientation of a plane that is more intuitive to users of this library?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gmggroup/omf/issues/33#issuecomment-456542592, or mute the thread https://github.com/notifications/unsubscribe-auth/AQR4CtSXl5dOgoINz01i17YMzy5XPM5hks5vF25lgaJpZM4aNA4T .