• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Numsgil

Distance between parallel lines under transformation

10 posts in this topic

I have a line (with points A, B on the line), and a distance 'h' to a parallel line.  Under an affine transformation, the lines should stay parallel, but the distance between them might change.  How can I get the new distance between the lines?
 
My thinking right now is to construct a point on the red line, transform that point with the affine transformation, and then find the distance of that new point to the transformed black line AB.  But is there a more direct way to calculate the new distance?
0

Share this post


Link to post
Share on other sites

I don't understand how there could be a more direct measurement, unless you're looking for an equation.

According to the definition from wolfram, an affine transformation is one that "preserves collinearity ... and ratios of distances."
Thus if you're scaling everything, the distance will scale with the lines as well. Thus new h = old h * scale amount. Otherwise the h will stay the same.

Hope this helps,

Selenaut

0

Share this post


Link to post
Share on other sites
That wording of "ratios of distances" is misleading. It only works for distances measured along the same line.

The only methods I can think of are essentially the same as what Numsgil came up with.
0

Share this post


Link to post
Share on other sites

The distance can be seen as the length of a direction vector d. The vector can be transformed as well, and the length of the vector after transformation is the distance of the lines after transformation.

 

Let d := |d| be the original length.

 

Uniform scaling S * d =: d' will cause d' = s * d, that's right. However, non-uniform scaling isn't that simple, because the direction of d plays a role. Moreover, if the transformation in question is a composite one w.r.t. the well known primitive transformations, then S is perhaps applied in a space where the direction of d isn't the same as those it is computed initially.

 

I think that for the most general case the transformation must be applied.

0

Share this post


Link to post
Share on other sites

Yeah, I dunno too much about affine transformations, I was kinda taking a stab in the dark there (just another example of how assumptions suck).

However, as haegarr stated, I think you answered your own question.

0

Share this post


Link to post
Share on other sites

Affine transformation is just another name for a matrix with non uniform scale, rotation, and translation baked in (more or less).  I didn't mean to be too obtuse when forming the question :)

 

Anyway, I came up with: h' = h * length(S*(b - a)) / (length(b - a)) after a bit of algebra.  Can someone confirm/refute that?  I took the method I described and worked it out algebraically.  But intuitively I'm surprised I'm using b-a and not a vector perpindicular to b-a or something along those lines.

0

Share this post


Link to post
Share on other sites

h' = h * length(S*(b - a)) / (length(b - a))


Um... Aren't you just multiplying by S then?

Think about what that says in plain english: The new 'h' is the old 'h' times the scaled length of a line, divided by the length of the same line. Edited by Ravyne
0

Share this post


Link to post
Share on other sites

Let points X and Y be arbitrary closest point pairs on the two lines. That is, X lies on the first line, and Y lies on the second line, and the distance between those two points is the same as the distance of the two lines themselves, i.e. in the original picture, h = |X-Y|.

Let H := X-Y =: (x,y,z,0). That is, H is a direction vector between the two points and it's length |H| = h is the distance between the two lines.

Let A be the affine map in question. Since A is affine, it is representible by a matrix M, using operation A(v) = M*v.

Then the sought new distance is

h' = |A(H)| = |M*H|

If the affine map A does contain shear and therefore M is not guaranteed to be orthonormal, then one can't do much better than to compute the matrix multiplication above.

If the affine map A does not contain any shearing, the formula does simplify: For ease of notation, fix ourselves to a 3D space (although 2D or other dimensions are equivalent). We can decompose the matrix M to a form M = N*S, where S is a diagonal matrix S=diag(sx,sy,sz,1) and N consists of column vectors vx,vy,vz,t, where vx, vy and vz are normalized and t is a translation component. That is, decompose the scaling part out of matrix M to matrix S.

Since A does not contain any shearing, the matrix N is orthonormal (only rotates, and potentially mirrors and its determinant is +/-1), and the new distance is

h' = |M*H| = |N*S*H| = |S*H| = |(sx*x,sy*y,sz*z)|

0

Share this post


Link to post
Share on other sites

@clb: I don't think you can do h' = |M*H| because M*H is not guaranteed to be a shortest path between the two parallel lines after they're transformed by M.

 

That is, just because H is perpendicular to both lines before transformation doesn't mean it's perpendicular to both lines after transformation.  Consider the case of a sheering of a square in to a parallelogram.  One of those funny properties of affine transformations: closest point pairs on parallel lines aren't preserved.

2

Share this post


Link to post
Share on other sites

Numsgil: You are absolutely correct.

 

For the case of no shear, it should hold. For the case with shear, I think it's possible to arrive to a closed expression by deriving the distance between the lines under the operation by the affine map, but that's indeed a more detailed examination.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0