Some trigonometric issue

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Some trigonometric issue

amundsen
Hello,

I have a rectangle abcd with known width w and height h.

The rectangle is rotated according to the theta angle and becomes ab'c'd'.

I can calculate the coordinates of the rotated rectangle. However my
knowledge in trigonometry is too weak to find the position of the point p on
the y axis. This point is at the intersection of the y-axis and the line
passing through the upper side of the rectangle after rotation.

Does anyone know how to calculate this? The distance between a and b' can be
easily calculated, but from there I am not quite sure how to proceed.

<http://forum.openscad.org/file/t2715/trigonometry_question.jpg>





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Some trigonometric issue

nophead
I think it is just  length(ab) /  acos(theta)

On Fri, 16 Oct 2020 at 11:29, amundsen <[hidden email]> wrote:
Hello,

I have a rectangle abcd with known width w and height h.

The rectangle is rotated according to the theta angle and becomes ab'c'd'.

I can calculate the coordinates of the rotated rectangle. However my
knowledge in trigonometry is too weak to find the position of the point p on
the y axis. This point is at the intersection of the y-axis and the line
passing through the upper side of the rectangle after rotation.

Does anyone know how to calculate this? The distance between a and b' can be
easily calculated, but from there I am not quite sure how to proceed.

<http://forum.openscad.org/file/t2715/trigonometry_question.jpg>





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
rew
Reply | Threaded
Open this post in threaded view
|

Re: Some trigonometric issue

rew
On Fri, Oct 16, 2020 at 11:34:41AM +0100, nop head wrote:
> I think it is just  length(ab) /  acos(theta)

Rotate the "whole figure" back along theta, but take the Y-axis along.

So now you want to find the intersection of the rotated Y-axis
and the upper side of your rectangle.

The line is: y/x = tan (theta).
and the topside of the rectangle is y = h

So I think you get h = tan (theta) * x or x = h/tan (theta)
So x,h  is the intersection point, and now you calculate the lenght from
the origin to find the Y-coordinate requested in the original question.
yp = sqrt (h*h +  h/tan (theta)* h/tan (theta))

You could/should check that x = h/tan (theta) is less than
w. Otherwise you're intersecting with the other edge of the rectangle.
But I'm guessing you have good reasons to believe that this will never
happen.

        Roger.


> On Fri, 16 Oct 2020 at 11:29, amundsen <[hidden email]> wrote:
>
> > Hello,
> >
> > I have a rectangle abcd with known width w and height h.
> >
> > The rectangle is rotated according to the theta angle and becomes ab'c'd'.
> >
> > I can calculate the coordinates of the rotated rectangle. However my
> > knowledge in trigonometry is too weak to find the position of the point p
> > on
> > the y axis. This point is at the intersection of the y-axis and the line
> > passing through the upper side of the rectangle after rotation.
> >
> > Does anyone know how to calculate this? The distance between a and b' can
> > be
> > easily calculated, but from there I am not quite sure how to proceed.
> >
> > <http://forum.openscad.org/file/t2715/trigonometry_question.jpg>
> >
> >
> >
> >
> >
> > --
> > Sent from: http://forum.openscad.org/
> >
> > _______________________________________________
> > OpenSCAD mailing list
> > [hidden email]
> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
> >

> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Some trigonometric issue

nophead
The triangle pab' is a right angle triangle and the angle pab' is equal to theta. So ab' / p = cos(theta). Hence p = ab' / cos(theta) and ab' = ab. So ab / cos(theta).

On Fri, 16 Oct 2020 at 11:53, Rogier Wolff <[hidden email]> wrote:
On Fri, Oct 16, 2020 at 11:34:41AM +0100, nop head wrote:
> I think it is just  length(ab) /  acos(theta)

Rotate the "whole figure" back along theta, but take the Y-axis along.

So now you want to find the intersection of the rotated Y-axis
and the upper side of your rectangle.

The line is: y/x = tan (theta).
and the topside of the rectangle is y = h

So I think you get h = tan (theta) * x or x = h/tan (theta)
So x,h  is the intersection point, and now you calculate the lenght from
the origin to find the Y-coordinate requested in the original question.
yp = sqrt (h*h +  h/tan (theta)* h/tan (theta))

You could/should check that x = h/tan (theta) is less than
w. Otherwise you're intersecting with the other edge of the rectangle.
But I'm guessing you have good reasons to believe that this will never
happen.

        Roger.


> On Fri, 16 Oct 2020 at 11:29, amundsen <[hidden email]> wrote:
>
> > Hello,
> >
> > I have a rectangle abcd with known width w and height h.
> >
> > The rectangle is rotated according to the theta angle and becomes ab'c'd'.
> >
> > I can calculate the coordinates of the rotated rectangle. However my
> > knowledge in trigonometry is too weak to find the position of the point p
> > on
> > the y axis. This point is at the intersection of the y-axis and the line
> > passing through the upper side of the rectangle after rotation.
> >
> > Does anyone know how to calculate this? The distance between a and b' can
> > be
> > easily calculated, but from there I am not quite sure how to proceed.
> >
> > <http://forum.openscad.org/file/t2715/trigonometry_question.jpg>
> >
> >
> >
> >
> >
> > --
> > Sent from: http://forum.openscad.org/
> >
> > _______________________________________________
> > OpenSCAD mailing list
> > [hidden email]
> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
> >

> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Some trigonometric issue

cacb
In reply to this post by amundsen
On 2020-10-16 12:28, amundsen wrote:
> I can calculate the coordinates of the rotated rectangle. However my
> knowledge in trigonometry is too weak to find the position of the point
> p on
> the y axis.

A general solution is based on 2 points on each line + using
determinants, details at:

https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection#Given_two_points_on_each_line

Se the formula for (Px,Py)

Regards
Carsten Arholm

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Some trigonometric issue

amundsen
In reply to this post by amundsen
ab/cos(theta) seems to give the right position.

Thank you everyone!



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
rew
Reply | Threaded
Open this post in threaded view
|

Re: Some trigonometric issue

rew
In reply to this post by nophead
On Fri, Oct 16, 2020 at 12:04:26PM +0100, nop head wrote:
> The triangle pab' is a right angle triangle and the angle pab' is equal to
> theta. So ab' / p = cos(theta). Hence p = ab' / cos(theta) and ab' = ab. So
> ab / cos(theta).

Although I might get a different formula... If I did things right the
result should be the same. It is possible that without pen-and-paper
I've done something wrong. And my trig is a bit rusty.

If you figure out a formula and want to double check it you can put in
the numbers that you can verify.

If my rectangle is 2 wide, 1 high and theta is 45deg. then the answer
should be sqrt (2).

if a is the width and b is the height, then ab/cos(theta) becomes 1.41
precisely the answer we expect....

But if our rectangle is 3 wide and the height and theta still 1 and 45
then the answer should still be 1.41 (sqrt(2)), but your formula gives
something else. The first example was a coincidence!

My formula however comes to yp = h * sqrt(1+1/tan(theta)^2) = sqrt(2)
for both examples. We can try a few more "known examples", but so far
my formula seems to do a bit better than yours.

        Roger.

P.S. I started out thinking that both formulas would come out to the
same number but it seems that this is not the case.


> On Fri, 16 Oct 2020 at 11:53, Rogier Wolff <[hidden email]> wrote:
>
> > On Fri, Oct 16, 2020 at 11:34:41AM +0100, nop head wrote:
> > > I think it is just  length(ab) /  acos(theta)
> >
> > Rotate the "whole figure" back along theta, but take the Y-axis along.
> >
> > So now you want to find the intersection of the rotated Y-axis
> > and the upper side of your rectangle.
> >
> > The line is: y/x = tan (theta).
> > and the topside of the rectangle is y = h
> >
> > So I think you get h = tan (theta) * x or x = h/tan (theta)
> > So x,h  is the intersection point, and now you calculate the lenght from
> > the origin to find the Y-coordinate requested in the original question.
> > yp = sqrt (h*h +  h/tan (theta)* h/tan (theta))
> >
> > You could/should check that x = h/tan (theta) is less than
> > w. Otherwise you're intersecting with the other edge of the rectangle.
> > But I'm guessing you have good reasons to believe that this will never
> > happen.
> >
> >         Roger.
> >
> >
> > > On Fri, 16 Oct 2020 at 11:29, amundsen <[hidden email]> wrote:
> > >
> > > > Hello,
> > > >
> > > > I have a rectangle abcd with known width w and height h.
> > > >
> > > > The rectangle is rotated according to the theta angle and becomes
> > ab'c'd'.
> > > >
> > > > I can calculate the coordinates of the rotated rectangle. However my
> > > > knowledge in trigonometry is too weak to find the position of the
> > point p
> > > > on
> > > > the y axis. This point is at the intersection of the y-axis and the
> > line
> > > > passing through the upper side of the rectangle after rotation.
> > > >
> > > > Does anyone know how to calculate this? The distance between a and b'
> > can
> > > > be
> > > > easily calculated, but from there I am not quite sure how to proceed.
> > > >
> > > > <http://forum.openscad.org/file/t2715/trigonometry_question.jpg>
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Sent from: http://forum.openscad.org/
> > > >
> > > > _______________________________________________
> > > > OpenSCAD mailing list
> > > > [hidden email]
> > > > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
> > > >
> >
> > > _______________________________________________
> > > OpenSCAD mailing list
> > > [hidden email]
> > > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
> >
> >
> > --
> > ** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110
> > **
> > **    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
> > f equals m times a. When your f is steady, and your m is going down
> > your a is going up.  -- Chris Hadfield about flying up the space shuttle.
> >
> > _______________________________________________
> > OpenSCAD mailing list
> > [hidden email]
> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
> >

> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Some trigonometric issue

nophead
Rogier,
  By ab I mean the length of the line ab, which is just the short side of the rectangle. The long side doesn't affect the position of p. You can ignore the rectangle completely and just trig on triangle pab' once you realise angle pab' is the same as theta.

On Fri, 16 Oct 2020 at 13:56, Rogier Wolff <[hidden email]> wrote:
On Fri, Oct 16, 2020 at 12:04:26PM +0100, nop head wrote:
> The triangle pab' is a right angle triangle and the angle pab' is equal to
> theta. So ab' / p = cos(theta). Hence p = ab' / cos(theta) and ab' = ab. So
> ab / cos(theta).

Although I might get a different formula... If I did things right the
result should be the same. It is possible that without pen-and-paper
I've done something wrong. And my trig is a bit rusty.

If you figure out a formula and want to double check it you can put in
the numbers that you can verify.

If my rectangle is 2 wide, 1 high and theta is 45deg. then the answer
should be sqrt (2).

if a is the width and b is the height, then ab/cos(theta) becomes 1.41
precisely the answer we expect....

But if our rectangle is 3 wide and the height and theta still 1 and 45
then the answer should still be 1.41 (sqrt(2)), but your formula gives
something else. The first example was a coincidence!

My formula however comes to yp = h * sqrt(1+1/tan(theta)^2) = sqrt(2)
for both examples. We can try a few more "known examples", but so far
my formula seems to do a bit better than yours.

        Roger.

P.S. I started out thinking that both formulas would come out to the
same number but it seems that this is not the case.


> On Fri, 16 Oct 2020 at 11:53, Rogier Wolff <[hidden email]> wrote:
>
> > On Fri, Oct 16, 2020 at 11:34:41AM +0100, nop head wrote:
> > > I think it is just  length(ab) /  acos(theta)
> >
> > Rotate the "whole figure" back along theta, but take the Y-axis along.
> >
> > So now you want to find the intersection of the rotated Y-axis
> > and the upper side of your rectangle.
> >
> > The line is: y/x = tan (theta).
> > and the topside of the rectangle is y = h
> >
> > So I think you get h = tan (theta) * x or x = h/tan (theta)
> > So x,h  is the intersection point, and now you calculate the lenght from
> > the origin to find the Y-coordinate requested in the original question.
> > yp = sqrt (h*h +  h/tan (theta)* h/tan (theta))
> >
> > You could/should check that x = h/tan (theta) is less than
> > w. Otherwise you're intersecting with the other edge of the rectangle.
> > But I'm guessing you have good reasons to believe that this will never
> > happen.
> >
> >         Roger.
> >
> >
> > > On Fri, 16 Oct 2020 at 11:29, amundsen <[hidden email]> wrote:
> > >
> > > > Hello,
> > > >
> > > > I have a rectangle abcd with known width w and height h.
> > > >
> > > > The rectangle is rotated according to the theta angle and becomes
> > ab'c'd'.
> > > >
> > > > I can calculate the coordinates of the rotated rectangle. However my
> > > > knowledge in trigonometry is too weak to find the position of the
> > point p
> > > > on
> > > > the y axis. This point is at the intersection of the y-axis and the
> > line
> > > > passing through the upper side of the rectangle after rotation.
> > > >
> > > > Does anyone know how to calculate this? The distance between a and b'
> > can
> > > > be
> > > > easily calculated, but from there I am not quite sure how to proceed.
> > > >
> > > > <http://forum.openscad.org/file/t2715/trigonometry_question.jpg>
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Sent from: http://forum.openscad.org/
> > > >
> > > > _______________________________________________
> > > > OpenSCAD mailing list
> > > > [hidden email]
> > > > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
> > > >
> >
> > > _______________________________________________
> > > OpenSCAD mailing list
> > > [hidden email]
> > > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
> >
> >
> > --
> > ** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110
> > **
> > **    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
> > f equals m times a. When your f is steady, and your m is going down
> > your a is going up.  -- Chris Hadfield about flying up the space shuttle.
> >
> > _______________________________________________
> > OpenSCAD mailing list
> > [hidden email]
> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
> >

> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
rew
Reply | Threaded
Open this post in threaded view
|

Re: Some trigonometric issue

rew
On Fri, Oct 16, 2020 at 03:33:45PM +0100, nop head wrote:
> Rogier,

>   By ab I mean the length of the line ab, which is just the short side of
> the rectangle. The long side doesn't affect the position of p. You can
> ignore the rectangle completely and just trig on triangle pab' once you
> realise angle pab' is the same as theta.

Hmm. Yeah looking at it that way I see your formula pop up
immediately... Seems I was doing something wrong. That's why I try to
check things with by putting in some "known" numbers...

        Roger.


--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a is going up.  -- Chris Hadfield about flying up the space shuttle.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org