Projection On Parallelogram












0














In my research, I encountered the problem of finding the projection of any point on given parallelogram with the following properties :



enter image description here




  1. If the point is in region 1, the projection should be vertex A.

  2. If the point is in region 2, the projection should be on segment AB parallel to Y-axis.

  3. If the point is in region 3, the projection should be vertex B.


And so on.



The equations of parallelogram sides are also given in the figure.



I am trying to find out a computational way to figure out this projection.



I tried to set up the problem as a minimum L1 distance to parallelogram from the given point. But, I realized that this is not the correct projection.



Can some one provide help on what would be the efficient computational way to figure out this kind of projection? I am totally new to this field - Any references are highly appreciated.



Thank you very much!










share|cite|improve this question
























  • There are some conditions to make clear: a) you said that AB is parallel to y axis, but then what are the dotted lines out of B indicating ? b) the arrow indicating the projection, is it normal to the edge ?, parallel to the axes ? ... c) the drawing is so distorted that looks to be in 3D, but equations are in 2d (?) You should provide a much cleaner scheme , before thinking to equations
    – G Cab
    Nov 15 '18 at 17:24












  • @GCab: a) AB is not parallel to y-axis. I meant the projection is parallel to y-axis. For example, let X be the given point in region 2 then Y is projection of X such that XY is parallel to Y-axis. b) Parallel to axes. c) The diagram is 2D and the shape is parallelogram and the describing equations are also in the diagram. Thank you very much for any help!
    – chandu1729
    Nov 16 '18 at 5:50
















0














In my research, I encountered the problem of finding the projection of any point on given parallelogram with the following properties :



enter image description here




  1. If the point is in region 1, the projection should be vertex A.

  2. If the point is in region 2, the projection should be on segment AB parallel to Y-axis.

  3. If the point is in region 3, the projection should be vertex B.


And so on.



The equations of parallelogram sides are also given in the figure.



I am trying to find out a computational way to figure out this projection.



I tried to set up the problem as a minimum L1 distance to parallelogram from the given point. But, I realized that this is not the correct projection.



Can some one provide help on what would be the efficient computational way to figure out this kind of projection? I am totally new to this field - Any references are highly appreciated.



Thank you very much!










share|cite|improve this question
























  • There are some conditions to make clear: a) you said that AB is parallel to y axis, but then what are the dotted lines out of B indicating ? b) the arrow indicating the projection, is it normal to the edge ?, parallel to the axes ? ... c) the drawing is so distorted that looks to be in 3D, but equations are in 2d (?) You should provide a much cleaner scheme , before thinking to equations
    – G Cab
    Nov 15 '18 at 17:24












  • @GCab: a) AB is not parallel to y-axis. I meant the projection is parallel to y-axis. For example, let X be the given point in region 2 then Y is projection of X such that XY is parallel to Y-axis. b) Parallel to axes. c) The diagram is 2D and the shape is parallelogram and the describing equations are also in the diagram. Thank you very much for any help!
    – chandu1729
    Nov 16 '18 at 5:50














0












0








0


0





In my research, I encountered the problem of finding the projection of any point on given parallelogram with the following properties :



enter image description here




  1. If the point is in region 1, the projection should be vertex A.

  2. If the point is in region 2, the projection should be on segment AB parallel to Y-axis.

  3. If the point is in region 3, the projection should be vertex B.


And so on.



The equations of parallelogram sides are also given in the figure.



I am trying to find out a computational way to figure out this projection.



I tried to set up the problem as a minimum L1 distance to parallelogram from the given point. But, I realized that this is not the correct projection.



Can some one provide help on what would be the efficient computational way to figure out this kind of projection? I am totally new to this field - Any references are highly appreciated.



Thank you very much!










share|cite|improve this question















In my research, I encountered the problem of finding the projection of any point on given parallelogram with the following properties :



enter image description here




  1. If the point is in region 1, the projection should be vertex A.

  2. If the point is in region 2, the projection should be on segment AB parallel to Y-axis.

  3. If the point is in region 3, the projection should be vertex B.


And so on.



The equations of parallelogram sides are also given in the figure.



I am trying to find out a computational way to figure out this projection.



I tried to set up the problem as a minimum L1 distance to parallelogram from the given point. But, I realized that this is not the correct projection.



Can some one provide help on what would be the efficient computational way to figure out this kind of projection? I am totally new to this field - Any references are highly appreciated.



Thank you very much!







geometry reference-request coordinate-systems projective-geometry computational-geometry






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Nov 27 '18 at 9:26









MBorg

1751114




1751114










asked Nov 15 '18 at 16:55









chandu1729

2,371821




2,371821












  • There are some conditions to make clear: a) you said that AB is parallel to y axis, but then what are the dotted lines out of B indicating ? b) the arrow indicating the projection, is it normal to the edge ?, parallel to the axes ? ... c) the drawing is so distorted that looks to be in 3D, but equations are in 2d (?) You should provide a much cleaner scheme , before thinking to equations
    – G Cab
    Nov 15 '18 at 17:24












  • @GCab: a) AB is not parallel to y-axis. I meant the projection is parallel to y-axis. For example, let X be the given point in region 2 then Y is projection of X such that XY is parallel to Y-axis. b) Parallel to axes. c) The diagram is 2D and the shape is parallelogram and the describing equations are also in the diagram. Thank you very much for any help!
    – chandu1729
    Nov 16 '18 at 5:50


















  • There are some conditions to make clear: a) you said that AB is parallel to y axis, but then what are the dotted lines out of B indicating ? b) the arrow indicating the projection, is it normal to the edge ?, parallel to the axes ? ... c) the drawing is so distorted that looks to be in 3D, but equations are in 2d (?) You should provide a much cleaner scheme , before thinking to equations
    – G Cab
    Nov 15 '18 at 17:24












  • @GCab: a) AB is not parallel to y-axis. I meant the projection is parallel to y-axis. For example, let X be the given point in region 2 then Y is projection of X such that XY is parallel to Y-axis. b) Parallel to axes. c) The diagram is 2D and the shape is parallelogram and the describing equations are also in the diagram. Thank you very much for any help!
    – chandu1729
    Nov 16 '18 at 5:50
















There are some conditions to make clear: a) you said that AB is parallel to y axis, but then what are the dotted lines out of B indicating ? b) the arrow indicating the projection, is it normal to the edge ?, parallel to the axes ? ... c) the drawing is so distorted that looks to be in 3D, but equations are in 2d (?) You should provide a much cleaner scheme , before thinking to equations
– G Cab
Nov 15 '18 at 17:24






There are some conditions to make clear: a) you said that AB is parallel to y axis, but then what are the dotted lines out of B indicating ? b) the arrow indicating the projection, is it normal to the edge ?, parallel to the axes ? ... c) the drawing is so distorted that looks to be in 3D, but equations are in 2d (?) You should provide a much cleaner scheme , before thinking to equations
– G Cab
Nov 15 '18 at 17:24














@GCab: a) AB is not parallel to y-axis. I meant the projection is parallel to y-axis. For example, let X be the given point in region 2 then Y is projection of X such that XY is parallel to Y-axis. b) Parallel to axes. c) The diagram is 2D and the shape is parallelogram and the describing equations are also in the diagram. Thank you very much for any help!
– chandu1729
Nov 16 '18 at 5:50




@GCab: a) AB is not parallel to y-axis. I meant the projection is parallel to y-axis. For example, let X be the given point in region 2 then Y is projection of X such that XY is parallel to Y-axis. b) Parallel to axes. c) The diagram is 2D and the shape is parallelogram and the describing equations are also in the diagram. Thank you very much for any help!
– chandu1729
Nov 16 '18 at 5:50










2 Answers
2






active

oldest

votes


















3














Parallog_Proj_1



So, each couple of lines given by
$$
b_{,1,,1} x + b_{,1,,2} y = pm 1
$$

and
$$
b_{,2,,1} x + b_{,2,,2} y = pm 1
$$

denotes a couple of lines symmetrical wrt the origin.



The four lines defines a parallelogram centered at the origin.



The four vertices are given by
$$
left( {matrix{
{A_{,p,,p} } & {A_{,p,,m} } & {A_{,m,,p} } & {A_{,m,,m} } cr } } right)
; : ; left( {matrix{
{b_{,1,,1} } & {b_{,1,,2} } cr
{b_{,2,,1} } & {b_{,2,,2} } cr
} } right)left( {matrix{ x cr y cr } } right)
= left( {matrix{
1 & 1 & { - 1} & { - 1} cr
1 & { - 1} & 1 & { - 1} cr
} } right)
$$

i.e.:
$$
left( {matrix{
{A_{,p,,p} } & {A_{,p,,m} } & {A_{,m,,p} } & {A_{,m,,m} } cr } } right)
= left( {matrix{ {b_{,1,,1} } & {b_{,1,,2} } cr {b_{,2,,1} } & {b_{,2,,2} } cr } } right)^{, - ,1}
left( {matrix{ 1 & 1 & { - 1} & { - 1} cr 1 & { - 1} & 1 & { - 1} cr } } right)
$$



If some of the $b$ values are negative the denomination of the A points will change
with respect to that shown in the figure: it is better to rearrange the denominations as to match
with that shown, i.e. lower, higher $x$, lower,higher $y$ coordinates.



Now, at each vertex attach three unitary vectors as shown.



Compute the projection of the vector $A_{p,m}P$ onto the unitary vectors $bf x_{pm}$ and $bf y_{pm}$ stemming from $A_{p,m}$.
If both projections are positive, then the point P lies in the $90^circ$ sector encompassed by those vectors
and $P$ projects onto the vertex itself.

Repeat for the other vertices and check if both projections are positive.



If P is not in any of the sector above, then express the vector $A_{p,m}P$ in the reference system given by $bf x_{pm}, , bf v_{pm}$.
If the coordinates in that system are both positive, then $P$ projects on the edge $A_{pm}A_{pp}$, and its
coordinate wrt $bf v_{pm}$ gives the distance from the vertex $A_{pm}.



You can see that the reference system $bf y_{pp}, , bf v_{pp}$ in $A_{pp}$ will cover the edge $A_{pp}A_{mp}$, and so on.

You can also see that $P$, if external to the parallelogram, can have both coordinates positive only in one of the four systems.



To translate the above into a computational algorithm we can proceed along the following lines.



Parallog_Proj_2



a) Construct the matrix
$$
{bf B} = left( {matrix{
{b_{,1,,1} } & {b_{,1,,2} } cr
{b_{,2,,1} } & {b_{,2,,2} } cr
} } right)
$$

ensure that its determinant is non null and compute $bf B^{-1}$.



b) Compute the four points A
$$
left( {matrix{ {A_{,p,,p} } & {A_{,p,,m} } & {A_{,m,,p} } & {A_{,m,,m} } cr } } right)
= {bf B}^{, - ,1} left( {matrix{ 1 & 1 & { - 1} & { - 1} cr 1 & { - 1} & 1 & { - 1} cr } } right)
$$



c) Rearrange points A

for instance by taking as pivot the point with minimal abscissa ($A_0$ in the sketch) and arranging the others
according to the tangent of the angle that they form with the pivot (if $Delta x = 0 ; to ; Delta x = epsilon $);

re-name the suffixes to $(0,1,2,3)$ so that they increase along the perimeter (e.g. ACW).



d) Construct unit vectors $bf u_n, ; v_n$
$$
eqalign{
& {bf v}_{,n} = overrightarrow {A_{,n} A_{,left( {n + 1} right)} } mathop {;/}limits_{} ;left| {overrightarrow {A_{,n} A_{,left( {n + 1} right)} } } right|quad left( {nbmod 4} right) cr
& {bf u}_{,n} = left( {matrix{
{cos left( {left( {n - 2} right)pi /2} right)} cr
{sin left( {left( {n - 2} right)pi /2} right)} cr
} } right) cr}
$$



e) Allocate the point P in the corresponding sector

construct the two lists
$$
L_{,x} = left[ {A_{,n,,x} ,P_{,x} } right]quad L_{,y} = left[ {A_{,n,,y} ,P_{,y} } right]
$$

and sort them in increasing order;



f) use the rank indices of P in the ordered lists to determine its position and projection

if (corner sector in $A_0$)
$P_{,x} < A_{,0,,x} ; wedge ;A_{,0,,y} < P_{,y} $ then $P to A_{,0} $ exit;

elif (lateral sector below $A_0$)
$P_{,x} < A_{,1,,x} ; wedge ;A_{,1,,y} < P_{,y} < A_{,0,,y} $ then

- take the matrix ${bf V}_{,0} = left( {matrix{ {{bf u}_{,0} } & {{bf v}_{,0} } cr } } right)$

- determine the coordinates of $P$ in that system
$$
left( {matrix{ {P'_x } cr {P'_y } cr } } right)
= {bf V}_{,0} ^{, - ,{bf 1}} ;left( {matrix{ {P_x } cr {P_y } cr } } right)
$$

- if $P'_y<0 ; to$ error;

- elif $P'_x<0 ; to$ the point is internal to the p., $to$ ?

- else $P; to ;A_{,0} + P'_y {bf v}_{,0} $

elif

....

(continue with the same path for the other sectors)






share|cite|improve this answer























  • Thanks for the response. I am not sure if I can code this - Do you think it can be expressed in a computational way? For example: We would like to write a function which takes the matrix B and point P (x,y) as inputs and computes (X,Y) as projection? Also, I would like to extend this Algorithm to high dimensions - so checking all the vertices will be susceptible to curse of dimensionality! Please let me know. Thanks Much.
    – chandu1729
    Nov 17 '18 at 19:27










  • @chandu1729: well I developed the answer mainly mathematically, but keeping an eye on computability. Mathematically (and computationally) I cannot see a better way. And it can be extended to 3D and higher. I am quite sure it is tranformable in an algorithm.
    – G Cab
    Nov 17 '18 at 21:16










  • @chandu1729: the difficulty, is mainly on rotation /reflection of the points for negative signs on the $b$'s. If the $b$'s are positive it should be quite viable.
    – G Cab
    Nov 17 '18 at 21:20










  • If I understand correctly, you are looking/traversing at each vertex. In n-dimensions there will be 2^n vertices which makes it exponential complexity!
    – chandu1729
    Nov 17 '18 at 21:24










  • I would highly appreciate if you can express your answer in an algorithmic way for general n-dimensional matrix B and point P. That will be easier for me to understand as well.
    – chandu1729
    Nov 17 '18 at 21:26



















1














In my solution $x_1, x_2$ are replaced by $x,y.$

The solution should be easy to code.



Assume the given straight lines are not horizontal neither vertical. In this case are all coefficients $b_{ij}neq 0.$

From the coefficients $pm 1$ in the equations follows that the parallelogram is centered in $O.$

Thus if $A(x_A,y_A), B(x_B,y_B),$ then necessarily $C(-x_A,-y_A), D(-x_B,-y_B).$



In the enclosed figure are the equations of the straight lines $color{blue}{blue},$ and located across the corresponding line.



enter image description here



Each region is determined by a system of inequations written in black.



The input point $P(x,y)$ has to be transformed to an output $P'(X,Y).$ These new coordinates $X,Y$ are written in the corresponding region in $color{red}{red}.$



Remark

If a pair of lines is horizontal or vertical (the product $prod_{i,j=1,2} b_{ij}=0$ ), the above solution has to be modified, but is easier.






share|cite|improve this answer























    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "69"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2999963%2fprojection-on-parallelogram%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    Parallog_Proj_1



    So, each couple of lines given by
    $$
    b_{,1,,1} x + b_{,1,,2} y = pm 1
    $$

    and
    $$
    b_{,2,,1} x + b_{,2,,2} y = pm 1
    $$

    denotes a couple of lines symmetrical wrt the origin.



    The four lines defines a parallelogram centered at the origin.



    The four vertices are given by
    $$
    left( {matrix{
    {A_{,p,,p} } & {A_{,p,,m} } & {A_{,m,,p} } & {A_{,m,,m} } cr } } right)
    ; : ; left( {matrix{
    {b_{,1,,1} } & {b_{,1,,2} } cr
    {b_{,2,,1} } & {b_{,2,,2} } cr
    } } right)left( {matrix{ x cr y cr } } right)
    = left( {matrix{
    1 & 1 & { - 1} & { - 1} cr
    1 & { - 1} & 1 & { - 1} cr
    } } right)
    $$

    i.e.:
    $$
    left( {matrix{
    {A_{,p,,p} } & {A_{,p,,m} } & {A_{,m,,p} } & {A_{,m,,m} } cr } } right)
    = left( {matrix{ {b_{,1,,1} } & {b_{,1,,2} } cr {b_{,2,,1} } & {b_{,2,,2} } cr } } right)^{, - ,1}
    left( {matrix{ 1 & 1 & { - 1} & { - 1} cr 1 & { - 1} & 1 & { - 1} cr } } right)
    $$



    If some of the $b$ values are negative the denomination of the A points will change
    with respect to that shown in the figure: it is better to rearrange the denominations as to match
    with that shown, i.e. lower, higher $x$, lower,higher $y$ coordinates.



    Now, at each vertex attach three unitary vectors as shown.



    Compute the projection of the vector $A_{p,m}P$ onto the unitary vectors $bf x_{pm}$ and $bf y_{pm}$ stemming from $A_{p,m}$.
    If both projections are positive, then the point P lies in the $90^circ$ sector encompassed by those vectors
    and $P$ projects onto the vertex itself.

    Repeat for the other vertices and check if both projections are positive.



    If P is not in any of the sector above, then express the vector $A_{p,m}P$ in the reference system given by $bf x_{pm}, , bf v_{pm}$.
    If the coordinates in that system are both positive, then $P$ projects on the edge $A_{pm}A_{pp}$, and its
    coordinate wrt $bf v_{pm}$ gives the distance from the vertex $A_{pm}.



    You can see that the reference system $bf y_{pp}, , bf v_{pp}$ in $A_{pp}$ will cover the edge $A_{pp}A_{mp}$, and so on.

    You can also see that $P$, if external to the parallelogram, can have both coordinates positive only in one of the four systems.



    To translate the above into a computational algorithm we can proceed along the following lines.



    Parallog_Proj_2



    a) Construct the matrix
    $$
    {bf B} = left( {matrix{
    {b_{,1,,1} } & {b_{,1,,2} } cr
    {b_{,2,,1} } & {b_{,2,,2} } cr
    } } right)
    $$

    ensure that its determinant is non null and compute $bf B^{-1}$.



    b) Compute the four points A
    $$
    left( {matrix{ {A_{,p,,p} } & {A_{,p,,m} } & {A_{,m,,p} } & {A_{,m,,m} } cr } } right)
    = {bf B}^{, - ,1} left( {matrix{ 1 & 1 & { - 1} & { - 1} cr 1 & { - 1} & 1 & { - 1} cr } } right)
    $$



    c) Rearrange points A

    for instance by taking as pivot the point with minimal abscissa ($A_0$ in the sketch) and arranging the others
    according to the tangent of the angle that they form with the pivot (if $Delta x = 0 ; to ; Delta x = epsilon $);

    re-name the suffixes to $(0,1,2,3)$ so that they increase along the perimeter (e.g. ACW).



    d) Construct unit vectors $bf u_n, ; v_n$
    $$
    eqalign{
    & {bf v}_{,n} = overrightarrow {A_{,n} A_{,left( {n + 1} right)} } mathop {;/}limits_{} ;left| {overrightarrow {A_{,n} A_{,left( {n + 1} right)} } } right|quad left( {nbmod 4} right) cr
    & {bf u}_{,n} = left( {matrix{
    {cos left( {left( {n - 2} right)pi /2} right)} cr
    {sin left( {left( {n - 2} right)pi /2} right)} cr
    } } right) cr}
    $$



    e) Allocate the point P in the corresponding sector

    construct the two lists
    $$
    L_{,x} = left[ {A_{,n,,x} ,P_{,x} } right]quad L_{,y} = left[ {A_{,n,,y} ,P_{,y} } right]
    $$

    and sort them in increasing order;



    f) use the rank indices of P in the ordered lists to determine its position and projection

    if (corner sector in $A_0$)
    $P_{,x} < A_{,0,,x} ; wedge ;A_{,0,,y} < P_{,y} $ then $P to A_{,0} $ exit;

    elif (lateral sector below $A_0$)
    $P_{,x} < A_{,1,,x} ; wedge ;A_{,1,,y} < P_{,y} < A_{,0,,y} $ then

    - take the matrix ${bf V}_{,0} = left( {matrix{ {{bf u}_{,0} } & {{bf v}_{,0} } cr } } right)$

    - determine the coordinates of $P$ in that system
    $$
    left( {matrix{ {P'_x } cr {P'_y } cr } } right)
    = {bf V}_{,0} ^{, - ,{bf 1}} ;left( {matrix{ {P_x } cr {P_y } cr } } right)
    $$

    - if $P'_y<0 ; to$ error;

    - elif $P'_x<0 ; to$ the point is internal to the p., $to$ ?

    - else $P; to ;A_{,0} + P'_y {bf v}_{,0} $

    elif

    ....

    (continue with the same path for the other sectors)






    share|cite|improve this answer























    • Thanks for the response. I am not sure if I can code this - Do you think it can be expressed in a computational way? For example: We would like to write a function which takes the matrix B and point P (x,y) as inputs and computes (X,Y) as projection? Also, I would like to extend this Algorithm to high dimensions - so checking all the vertices will be susceptible to curse of dimensionality! Please let me know. Thanks Much.
      – chandu1729
      Nov 17 '18 at 19:27










    • @chandu1729: well I developed the answer mainly mathematically, but keeping an eye on computability. Mathematically (and computationally) I cannot see a better way. And it can be extended to 3D and higher. I am quite sure it is tranformable in an algorithm.
      – G Cab
      Nov 17 '18 at 21:16










    • @chandu1729: the difficulty, is mainly on rotation /reflection of the points for negative signs on the $b$'s. If the $b$'s are positive it should be quite viable.
      – G Cab
      Nov 17 '18 at 21:20










    • If I understand correctly, you are looking/traversing at each vertex. In n-dimensions there will be 2^n vertices which makes it exponential complexity!
      – chandu1729
      Nov 17 '18 at 21:24










    • I would highly appreciate if you can express your answer in an algorithmic way for general n-dimensional matrix B and point P. That will be easier for me to understand as well.
      – chandu1729
      Nov 17 '18 at 21:26
















    3














    Parallog_Proj_1



    So, each couple of lines given by
    $$
    b_{,1,,1} x + b_{,1,,2} y = pm 1
    $$

    and
    $$
    b_{,2,,1} x + b_{,2,,2} y = pm 1
    $$

    denotes a couple of lines symmetrical wrt the origin.



    The four lines defines a parallelogram centered at the origin.



    The four vertices are given by
    $$
    left( {matrix{
    {A_{,p,,p} } & {A_{,p,,m} } & {A_{,m,,p} } & {A_{,m,,m} } cr } } right)
    ; : ; left( {matrix{
    {b_{,1,,1} } & {b_{,1,,2} } cr
    {b_{,2,,1} } & {b_{,2,,2} } cr
    } } right)left( {matrix{ x cr y cr } } right)
    = left( {matrix{
    1 & 1 & { - 1} & { - 1} cr
    1 & { - 1} & 1 & { - 1} cr
    } } right)
    $$

    i.e.:
    $$
    left( {matrix{
    {A_{,p,,p} } & {A_{,p,,m} } & {A_{,m,,p} } & {A_{,m,,m} } cr } } right)
    = left( {matrix{ {b_{,1,,1} } & {b_{,1,,2} } cr {b_{,2,,1} } & {b_{,2,,2} } cr } } right)^{, - ,1}
    left( {matrix{ 1 & 1 & { - 1} & { - 1} cr 1 & { - 1} & 1 & { - 1} cr } } right)
    $$



    If some of the $b$ values are negative the denomination of the A points will change
    with respect to that shown in the figure: it is better to rearrange the denominations as to match
    with that shown, i.e. lower, higher $x$, lower,higher $y$ coordinates.



    Now, at each vertex attach three unitary vectors as shown.



    Compute the projection of the vector $A_{p,m}P$ onto the unitary vectors $bf x_{pm}$ and $bf y_{pm}$ stemming from $A_{p,m}$.
    If both projections are positive, then the point P lies in the $90^circ$ sector encompassed by those vectors
    and $P$ projects onto the vertex itself.

    Repeat for the other vertices and check if both projections are positive.



    If P is not in any of the sector above, then express the vector $A_{p,m}P$ in the reference system given by $bf x_{pm}, , bf v_{pm}$.
    If the coordinates in that system are both positive, then $P$ projects on the edge $A_{pm}A_{pp}$, and its
    coordinate wrt $bf v_{pm}$ gives the distance from the vertex $A_{pm}.



    You can see that the reference system $bf y_{pp}, , bf v_{pp}$ in $A_{pp}$ will cover the edge $A_{pp}A_{mp}$, and so on.

    You can also see that $P$, if external to the parallelogram, can have both coordinates positive only in one of the four systems.



    To translate the above into a computational algorithm we can proceed along the following lines.



    Parallog_Proj_2



    a) Construct the matrix
    $$
    {bf B} = left( {matrix{
    {b_{,1,,1} } & {b_{,1,,2} } cr
    {b_{,2,,1} } & {b_{,2,,2} } cr
    } } right)
    $$

    ensure that its determinant is non null and compute $bf B^{-1}$.



    b) Compute the four points A
    $$
    left( {matrix{ {A_{,p,,p} } & {A_{,p,,m} } & {A_{,m,,p} } & {A_{,m,,m} } cr } } right)
    = {bf B}^{, - ,1} left( {matrix{ 1 & 1 & { - 1} & { - 1} cr 1 & { - 1} & 1 & { - 1} cr } } right)
    $$



    c) Rearrange points A

    for instance by taking as pivot the point with minimal abscissa ($A_0$ in the sketch) and arranging the others
    according to the tangent of the angle that they form with the pivot (if $Delta x = 0 ; to ; Delta x = epsilon $);

    re-name the suffixes to $(0,1,2,3)$ so that they increase along the perimeter (e.g. ACW).



    d) Construct unit vectors $bf u_n, ; v_n$
    $$
    eqalign{
    & {bf v}_{,n} = overrightarrow {A_{,n} A_{,left( {n + 1} right)} } mathop {;/}limits_{} ;left| {overrightarrow {A_{,n} A_{,left( {n + 1} right)} } } right|quad left( {nbmod 4} right) cr
    & {bf u}_{,n} = left( {matrix{
    {cos left( {left( {n - 2} right)pi /2} right)} cr
    {sin left( {left( {n - 2} right)pi /2} right)} cr
    } } right) cr}
    $$



    e) Allocate the point P in the corresponding sector

    construct the two lists
    $$
    L_{,x} = left[ {A_{,n,,x} ,P_{,x} } right]quad L_{,y} = left[ {A_{,n,,y} ,P_{,y} } right]
    $$

    and sort them in increasing order;



    f) use the rank indices of P in the ordered lists to determine its position and projection

    if (corner sector in $A_0$)
    $P_{,x} < A_{,0,,x} ; wedge ;A_{,0,,y} < P_{,y} $ then $P to A_{,0} $ exit;

    elif (lateral sector below $A_0$)
    $P_{,x} < A_{,1,,x} ; wedge ;A_{,1,,y} < P_{,y} < A_{,0,,y} $ then

    - take the matrix ${bf V}_{,0} = left( {matrix{ {{bf u}_{,0} } & {{bf v}_{,0} } cr } } right)$

    - determine the coordinates of $P$ in that system
    $$
    left( {matrix{ {P'_x } cr {P'_y } cr } } right)
    = {bf V}_{,0} ^{, - ,{bf 1}} ;left( {matrix{ {P_x } cr {P_y } cr } } right)
    $$

    - if $P'_y<0 ; to$ error;

    - elif $P'_x<0 ; to$ the point is internal to the p., $to$ ?

    - else $P; to ;A_{,0} + P'_y {bf v}_{,0} $

    elif

    ....

    (continue with the same path for the other sectors)






    share|cite|improve this answer























    • Thanks for the response. I am not sure if I can code this - Do you think it can be expressed in a computational way? For example: We would like to write a function which takes the matrix B and point P (x,y) as inputs and computes (X,Y) as projection? Also, I would like to extend this Algorithm to high dimensions - so checking all the vertices will be susceptible to curse of dimensionality! Please let me know. Thanks Much.
      – chandu1729
      Nov 17 '18 at 19:27










    • @chandu1729: well I developed the answer mainly mathematically, but keeping an eye on computability. Mathematically (and computationally) I cannot see a better way. And it can be extended to 3D and higher. I am quite sure it is tranformable in an algorithm.
      – G Cab
      Nov 17 '18 at 21:16










    • @chandu1729: the difficulty, is mainly on rotation /reflection of the points for negative signs on the $b$'s. If the $b$'s are positive it should be quite viable.
      – G Cab
      Nov 17 '18 at 21:20










    • If I understand correctly, you are looking/traversing at each vertex. In n-dimensions there will be 2^n vertices which makes it exponential complexity!
      – chandu1729
      Nov 17 '18 at 21:24










    • I would highly appreciate if you can express your answer in an algorithmic way for general n-dimensional matrix B and point P. That will be easier for me to understand as well.
      – chandu1729
      Nov 17 '18 at 21:26














    3












    3








    3






    Parallog_Proj_1



    So, each couple of lines given by
    $$
    b_{,1,,1} x + b_{,1,,2} y = pm 1
    $$

    and
    $$
    b_{,2,,1} x + b_{,2,,2} y = pm 1
    $$

    denotes a couple of lines symmetrical wrt the origin.



    The four lines defines a parallelogram centered at the origin.



    The four vertices are given by
    $$
    left( {matrix{
    {A_{,p,,p} } & {A_{,p,,m} } & {A_{,m,,p} } & {A_{,m,,m} } cr } } right)
    ; : ; left( {matrix{
    {b_{,1,,1} } & {b_{,1,,2} } cr
    {b_{,2,,1} } & {b_{,2,,2} } cr
    } } right)left( {matrix{ x cr y cr } } right)
    = left( {matrix{
    1 & 1 & { - 1} & { - 1} cr
    1 & { - 1} & 1 & { - 1} cr
    } } right)
    $$

    i.e.:
    $$
    left( {matrix{
    {A_{,p,,p} } & {A_{,p,,m} } & {A_{,m,,p} } & {A_{,m,,m} } cr } } right)
    = left( {matrix{ {b_{,1,,1} } & {b_{,1,,2} } cr {b_{,2,,1} } & {b_{,2,,2} } cr } } right)^{, - ,1}
    left( {matrix{ 1 & 1 & { - 1} & { - 1} cr 1 & { - 1} & 1 & { - 1} cr } } right)
    $$



    If some of the $b$ values are negative the denomination of the A points will change
    with respect to that shown in the figure: it is better to rearrange the denominations as to match
    with that shown, i.e. lower, higher $x$, lower,higher $y$ coordinates.



    Now, at each vertex attach three unitary vectors as shown.



    Compute the projection of the vector $A_{p,m}P$ onto the unitary vectors $bf x_{pm}$ and $bf y_{pm}$ stemming from $A_{p,m}$.
    If both projections are positive, then the point P lies in the $90^circ$ sector encompassed by those vectors
    and $P$ projects onto the vertex itself.

    Repeat for the other vertices and check if both projections are positive.



    If P is not in any of the sector above, then express the vector $A_{p,m}P$ in the reference system given by $bf x_{pm}, , bf v_{pm}$.
    If the coordinates in that system are both positive, then $P$ projects on the edge $A_{pm}A_{pp}$, and its
    coordinate wrt $bf v_{pm}$ gives the distance from the vertex $A_{pm}.



    You can see that the reference system $bf y_{pp}, , bf v_{pp}$ in $A_{pp}$ will cover the edge $A_{pp}A_{mp}$, and so on.

    You can also see that $P$, if external to the parallelogram, can have both coordinates positive only in one of the four systems.



    To translate the above into a computational algorithm we can proceed along the following lines.



    Parallog_Proj_2



    a) Construct the matrix
    $$
    {bf B} = left( {matrix{
    {b_{,1,,1} } & {b_{,1,,2} } cr
    {b_{,2,,1} } & {b_{,2,,2} } cr
    } } right)
    $$

    ensure that its determinant is non null and compute $bf B^{-1}$.



    b) Compute the four points A
    $$
    left( {matrix{ {A_{,p,,p} } & {A_{,p,,m} } & {A_{,m,,p} } & {A_{,m,,m} } cr } } right)
    = {bf B}^{, - ,1} left( {matrix{ 1 & 1 & { - 1} & { - 1} cr 1 & { - 1} & 1 & { - 1} cr } } right)
    $$



    c) Rearrange points A

    for instance by taking as pivot the point with minimal abscissa ($A_0$ in the sketch) and arranging the others
    according to the tangent of the angle that they form with the pivot (if $Delta x = 0 ; to ; Delta x = epsilon $);

    re-name the suffixes to $(0,1,2,3)$ so that they increase along the perimeter (e.g. ACW).



    d) Construct unit vectors $bf u_n, ; v_n$
    $$
    eqalign{
    & {bf v}_{,n} = overrightarrow {A_{,n} A_{,left( {n + 1} right)} } mathop {;/}limits_{} ;left| {overrightarrow {A_{,n} A_{,left( {n + 1} right)} } } right|quad left( {nbmod 4} right) cr
    & {bf u}_{,n} = left( {matrix{
    {cos left( {left( {n - 2} right)pi /2} right)} cr
    {sin left( {left( {n - 2} right)pi /2} right)} cr
    } } right) cr}
    $$



    e) Allocate the point P in the corresponding sector

    construct the two lists
    $$
    L_{,x} = left[ {A_{,n,,x} ,P_{,x} } right]quad L_{,y} = left[ {A_{,n,,y} ,P_{,y} } right]
    $$

    and sort them in increasing order;



    f) use the rank indices of P in the ordered lists to determine its position and projection

    if (corner sector in $A_0$)
    $P_{,x} < A_{,0,,x} ; wedge ;A_{,0,,y} < P_{,y} $ then $P to A_{,0} $ exit;

    elif (lateral sector below $A_0$)
    $P_{,x} < A_{,1,,x} ; wedge ;A_{,1,,y} < P_{,y} < A_{,0,,y} $ then

    - take the matrix ${bf V}_{,0} = left( {matrix{ {{bf u}_{,0} } & {{bf v}_{,0} } cr } } right)$

    - determine the coordinates of $P$ in that system
    $$
    left( {matrix{ {P'_x } cr {P'_y } cr } } right)
    = {bf V}_{,0} ^{, - ,{bf 1}} ;left( {matrix{ {P_x } cr {P_y } cr } } right)
    $$

    - if $P'_y<0 ; to$ error;

    - elif $P'_x<0 ; to$ the point is internal to the p., $to$ ?

    - else $P; to ;A_{,0} + P'_y {bf v}_{,0} $

    elif

    ....

    (continue with the same path for the other sectors)






    share|cite|improve this answer














    Parallog_Proj_1



    So, each couple of lines given by
    $$
    b_{,1,,1} x + b_{,1,,2} y = pm 1
    $$

    and
    $$
    b_{,2,,1} x + b_{,2,,2} y = pm 1
    $$

    denotes a couple of lines symmetrical wrt the origin.



    The four lines defines a parallelogram centered at the origin.



    The four vertices are given by
    $$
    left( {matrix{
    {A_{,p,,p} } & {A_{,p,,m} } & {A_{,m,,p} } & {A_{,m,,m} } cr } } right)
    ; : ; left( {matrix{
    {b_{,1,,1} } & {b_{,1,,2} } cr
    {b_{,2,,1} } & {b_{,2,,2} } cr
    } } right)left( {matrix{ x cr y cr } } right)
    = left( {matrix{
    1 & 1 & { - 1} & { - 1} cr
    1 & { - 1} & 1 & { - 1} cr
    } } right)
    $$

    i.e.:
    $$
    left( {matrix{
    {A_{,p,,p} } & {A_{,p,,m} } & {A_{,m,,p} } & {A_{,m,,m} } cr } } right)
    = left( {matrix{ {b_{,1,,1} } & {b_{,1,,2} } cr {b_{,2,,1} } & {b_{,2,,2} } cr } } right)^{, - ,1}
    left( {matrix{ 1 & 1 & { - 1} & { - 1} cr 1 & { - 1} & 1 & { - 1} cr } } right)
    $$



    If some of the $b$ values are negative the denomination of the A points will change
    with respect to that shown in the figure: it is better to rearrange the denominations as to match
    with that shown, i.e. lower, higher $x$, lower,higher $y$ coordinates.



    Now, at each vertex attach three unitary vectors as shown.



    Compute the projection of the vector $A_{p,m}P$ onto the unitary vectors $bf x_{pm}$ and $bf y_{pm}$ stemming from $A_{p,m}$.
    If both projections are positive, then the point P lies in the $90^circ$ sector encompassed by those vectors
    and $P$ projects onto the vertex itself.

    Repeat for the other vertices and check if both projections are positive.



    If P is not in any of the sector above, then express the vector $A_{p,m}P$ in the reference system given by $bf x_{pm}, , bf v_{pm}$.
    If the coordinates in that system are both positive, then $P$ projects on the edge $A_{pm}A_{pp}$, and its
    coordinate wrt $bf v_{pm}$ gives the distance from the vertex $A_{pm}.



    You can see that the reference system $bf y_{pp}, , bf v_{pp}$ in $A_{pp}$ will cover the edge $A_{pp}A_{mp}$, and so on.

    You can also see that $P$, if external to the parallelogram, can have both coordinates positive only in one of the four systems.



    To translate the above into a computational algorithm we can proceed along the following lines.



    Parallog_Proj_2



    a) Construct the matrix
    $$
    {bf B} = left( {matrix{
    {b_{,1,,1} } & {b_{,1,,2} } cr
    {b_{,2,,1} } & {b_{,2,,2} } cr
    } } right)
    $$

    ensure that its determinant is non null and compute $bf B^{-1}$.



    b) Compute the four points A
    $$
    left( {matrix{ {A_{,p,,p} } & {A_{,p,,m} } & {A_{,m,,p} } & {A_{,m,,m} } cr } } right)
    = {bf B}^{, - ,1} left( {matrix{ 1 & 1 & { - 1} & { - 1} cr 1 & { - 1} & 1 & { - 1} cr } } right)
    $$



    c) Rearrange points A

    for instance by taking as pivot the point with minimal abscissa ($A_0$ in the sketch) and arranging the others
    according to the tangent of the angle that they form with the pivot (if $Delta x = 0 ; to ; Delta x = epsilon $);

    re-name the suffixes to $(0,1,2,3)$ so that they increase along the perimeter (e.g. ACW).



    d) Construct unit vectors $bf u_n, ; v_n$
    $$
    eqalign{
    & {bf v}_{,n} = overrightarrow {A_{,n} A_{,left( {n + 1} right)} } mathop {;/}limits_{} ;left| {overrightarrow {A_{,n} A_{,left( {n + 1} right)} } } right|quad left( {nbmod 4} right) cr
    & {bf u}_{,n} = left( {matrix{
    {cos left( {left( {n - 2} right)pi /2} right)} cr
    {sin left( {left( {n - 2} right)pi /2} right)} cr
    } } right) cr}
    $$



    e) Allocate the point P in the corresponding sector

    construct the two lists
    $$
    L_{,x} = left[ {A_{,n,,x} ,P_{,x} } right]quad L_{,y} = left[ {A_{,n,,y} ,P_{,y} } right]
    $$

    and sort them in increasing order;



    f) use the rank indices of P in the ordered lists to determine its position and projection

    if (corner sector in $A_0$)
    $P_{,x} < A_{,0,,x} ; wedge ;A_{,0,,y} < P_{,y} $ then $P to A_{,0} $ exit;

    elif (lateral sector below $A_0$)
    $P_{,x} < A_{,1,,x} ; wedge ;A_{,1,,y} < P_{,y} < A_{,0,,y} $ then

    - take the matrix ${bf V}_{,0} = left( {matrix{ {{bf u}_{,0} } & {{bf v}_{,0} } cr } } right)$

    - determine the coordinates of $P$ in that system
    $$
    left( {matrix{ {P'_x } cr {P'_y } cr } } right)
    = {bf V}_{,0} ^{, - ,{bf 1}} ;left( {matrix{ {P_x } cr {P_y } cr } } right)
    $$

    - if $P'_y<0 ; to$ error;

    - elif $P'_x<0 ; to$ the point is internal to the p., $to$ ?

    - else $P; to ;A_{,0} + P'_y {bf v}_{,0} $

    elif

    ....

    (continue with the same path for the other sectors)







    share|cite|improve this answer














    share|cite|improve this answer



    share|cite|improve this answer








    edited Nov 21 '18 at 17:29

























    answered Nov 17 '18 at 1:04









    G Cab

    17.9k31237




    17.9k31237












    • Thanks for the response. I am not sure if I can code this - Do you think it can be expressed in a computational way? For example: We would like to write a function which takes the matrix B and point P (x,y) as inputs and computes (X,Y) as projection? Also, I would like to extend this Algorithm to high dimensions - so checking all the vertices will be susceptible to curse of dimensionality! Please let me know. Thanks Much.
      – chandu1729
      Nov 17 '18 at 19:27










    • @chandu1729: well I developed the answer mainly mathematically, but keeping an eye on computability. Mathematically (and computationally) I cannot see a better way. And it can be extended to 3D and higher. I am quite sure it is tranformable in an algorithm.
      – G Cab
      Nov 17 '18 at 21:16










    • @chandu1729: the difficulty, is mainly on rotation /reflection of the points for negative signs on the $b$'s. If the $b$'s are positive it should be quite viable.
      – G Cab
      Nov 17 '18 at 21:20










    • If I understand correctly, you are looking/traversing at each vertex. In n-dimensions there will be 2^n vertices which makes it exponential complexity!
      – chandu1729
      Nov 17 '18 at 21:24










    • I would highly appreciate if you can express your answer in an algorithmic way for general n-dimensional matrix B and point P. That will be easier for me to understand as well.
      – chandu1729
      Nov 17 '18 at 21:26


















    • Thanks for the response. I am not sure if I can code this - Do you think it can be expressed in a computational way? For example: We would like to write a function which takes the matrix B and point P (x,y) as inputs and computes (X,Y) as projection? Also, I would like to extend this Algorithm to high dimensions - so checking all the vertices will be susceptible to curse of dimensionality! Please let me know. Thanks Much.
      – chandu1729
      Nov 17 '18 at 19:27










    • @chandu1729: well I developed the answer mainly mathematically, but keeping an eye on computability. Mathematically (and computationally) I cannot see a better way. And it can be extended to 3D and higher. I am quite sure it is tranformable in an algorithm.
      – G Cab
      Nov 17 '18 at 21:16










    • @chandu1729: the difficulty, is mainly on rotation /reflection of the points for negative signs on the $b$'s. If the $b$'s are positive it should be quite viable.
      – G Cab
      Nov 17 '18 at 21:20










    • If I understand correctly, you are looking/traversing at each vertex. In n-dimensions there will be 2^n vertices which makes it exponential complexity!
      – chandu1729
      Nov 17 '18 at 21:24










    • I would highly appreciate if you can express your answer in an algorithmic way for general n-dimensional matrix B and point P. That will be easier for me to understand as well.
      – chandu1729
      Nov 17 '18 at 21:26
















    Thanks for the response. I am not sure if I can code this - Do you think it can be expressed in a computational way? For example: We would like to write a function which takes the matrix B and point P (x,y) as inputs and computes (X,Y) as projection? Also, I would like to extend this Algorithm to high dimensions - so checking all the vertices will be susceptible to curse of dimensionality! Please let me know. Thanks Much.
    – chandu1729
    Nov 17 '18 at 19:27




    Thanks for the response. I am not sure if I can code this - Do you think it can be expressed in a computational way? For example: We would like to write a function which takes the matrix B and point P (x,y) as inputs and computes (X,Y) as projection? Also, I would like to extend this Algorithm to high dimensions - so checking all the vertices will be susceptible to curse of dimensionality! Please let me know. Thanks Much.
    – chandu1729
    Nov 17 '18 at 19:27












    @chandu1729: well I developed the answer mainly mathematically, but keeping an eye on computability. Mathematically (and computationally) I cannot see a better way. And it can be extended to 3D and higher. I am quite sure it is tranformable in an algorithm.
    – G Cab
    Nov 17 '18 at 21:16




    @chandu1729: well I developed the answer mainly mathematically, but keeping an eye on computability. Mathematically (and computationally) I cannot see a better way. And it can be extended to 3D and higher. I am quite sure it is tranformable in an algorithm.
    – G Cab
    Nov 17 '18 at 21:16












    @chandu1729: the difficulty, is mainly on rotation /reflection of the points for negative signs on the $b$'s. If the $b$'s are positive it should be quite viable.
    – G Cab
    Nov 17 '18 at 21:20




    @chandu1729: the difficulty, is mainly on rotation /reflection of the points for negative signs on the $b$'s. If the $b$'s are positive it should be quite viable.
    – G Cab
    Nov 17 '18 at 21:20












    If I understand correctly, you are looking/traversing at each vertex. In n-dimensions there will be 2^n vertices which makes it exponential complexity!
    – chandu1729
    Nov 17 '18 at 21:24




    If I understand correctly, you are looking/traversing at each vertex. In n-dimensions there will be 2^n vertices which makes it exponential complexity!
    – chandu1729
    Nov 17 '18 at 21:24












    I would highly appreciate if you can express your answer in an algorithmic way for general n-dimensional matrix B and point P. That will be easier for me to understand as well.
    – chandu1729
    Nov 17 '18 at 21:26




    I would highly appreciate if you can express your answer in an algorithmic way for general n-dimensional matrix B and point P. That will be easier for me to understand as well.
    – chandu1729
    Nov 17 '18 at 21:26











    1














    In my solution $x_1, x_2$ are replaced by $x,y.$

    The solution should be easy to code.



    Assume the given straight lines are not horizontal neither vertical. In this case are all coefficients $b_{ij}neq 0.$

    From the coefficients $pm 1$ in the equations follows that the parallelogram is centered in $O.$

    Thus if $A(x_A,y_A), B(x_B,y_B),$ then necessarily $C(-x_A,-y_A), D(-x_B,-y_B).$



    In the enclosed figure are the equations of the straight lines $color{blue}{blue},$ and located across the corresponding line.



    enter image description here



    Each region is determined by a system of inequations written in black.



    The input point $P(x,y)$ has to be transformed to an output $P'(X,Y).$ These new coordinates $X,Y$ are written in the corresponding region in $color{red}{red}.$



    Remark

    If a pair of lines is horizontal or vertical (the product $prod_{i,j=1,2} b_{ij}=0$ ), the above solution has to be modified, but is easier.






    share|cite|improve this answer




























      1














      In my solution $x_1, x_2$ are replaced by $x,y.$

      The solution should be easy to code.



      Assume the given straight lines are not horizontal neither vertical. In this case are all coefficients $b_{ij}neq 0.$

      From the coefficients $pm 1$ in the equations follows that the parallelogram is centered in $O.$

      Thus if $A(x_A,y_A), B(x_B,y_B),$ then necessarily $C(-x_A,-y_A), D(-x_B,-y_B).$



      In the enclosed figure are the equations of the straight lines $color{blue}{blue},$ and located across the corresponding line.



      enter image description here



      Each region is determined by a system of inequations written in black.



      The input point $P(x,y)$ has to be transformed to an output $P'(X,Y).$ These new coordinates $X,Y$ are written in the corresponding region in $color{red}{red}.$



      Remark

      If a pair of lines is horizontal or vertical (the product $prod_{i,j=1,2} b_{ij}=0$ ), the above solution has to be modified, but is easier.






      share|cite|improve this answer


























        1












        1








        1






        In my solution $x_1, x_2$ are replaced by $x,y.$

        The solution should be easy to code.



        Assume the given straight lines are not horizontal neither vertical. In this case are all coefficients $b_{ij}neq 0.$

        From the coefficients $pm 1$ in the equations follows that the parallelogram is centered in $O.$

        Thus if $A(x_A,y_A), B(x_B,y_B),$ then necessarily $C(-x_A,-y_A), D(-x_B,-y_B).$



        In the enclosed figure are the equations of the straight lines $color{blue}{blue},$ and located across the corresponding line.



        enter image description here



        Each region is determined by a system of inequations written in black.



        The input point $P(x,y)$ has to be transformed to an output $P'(X,Y).$ These new coordinates $X,Y$ are written in the corresponding region in $color{red}{red}.$



        Remark

        If a pair of lines is horizontal or vertical (the product $prod_{i,j=1,2} b_{ij}=0$ ), the above solution has to be modified, but is easier.






        share|cite|improve this answer














        In my solution $x_1, x_2$ are replaced by $x,y.$

        The solution should be easy to code.



        Assume the given straight lines are not horizontal neither vertical. In this case are all coefficients $b_{ij}neq 0.$

        From the coefficients $pm 1$ in the equations follows that the parallelogram is centered in $O.$

        Thus if $A(x_A,y_A), B(x_B,y_B),$ then necessarily $C(-x_A,-y_A), D(-x_B,-y_B).$



        In the enclosed figure are the equations of the straight lines $color{blue}{blue},$ and located across the corresponding line.



        enter image description here



        Each region is determined by a system of inequations written in black.



        The input point $P(x,y)$ has to be transformed to an output $P'(X,Y).$ These new coordinates $X,Y$ are written in the corresponding region in $color{red}{red}.$



        Remark

        If a pair of lines is horizontal or vertical (the product $prod_{i,j=1,2} b_{ij}=0$ ), the above solution has to be modified, but is easier.







        share|cite|improve this answer














        share|cite|improve this answer



        share|cite|improve this answer








        edited Nov 28 '18 at 8:32

























        answered Nov 24 '18 at 13:39









        user376343

        2,8582823




        2,8582823






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematics Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2999963%2fprojection-on-parallelogram%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

            Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

            A Topological Invariant for $pi_3(U(n))$