Get current zooming factor

Clueid shared this question 4 months ago
Answered

Hello,

What is the script for getting current zooming factor of the GeoGebra view?


Background: in the example of snapping a point to other object or point, the boolean (distance() < 0.1) triggers snapping the point through DynamicCoordinates. How can we set 0.1 to be a number proportional to the zooming factor, such that when the object is zoomed in, the same amount of "magniticy" is applied. (consider for example when you zoom in to more than distance of 0.1, what will happen when you try to get the point out of the snapping zone?)

Best Answer
photo

zoomin is undependent for each axes so the general answer is not possible

if you want the zoom for xAxis you can do (x(Corner(5)) + 2) / 50 / x(Corner(3) - Corner(1))

Comments (16)

photo
3

Hi,

https://wiki.geogebra.org/en/ZoomIn_Command

https://wiki.geogebra.org/en/ZoomOut_Command

"Current zooming factor" does not exist.

However you may want to read

https://wiki.geogebra.org/en/Corner_Command

You can calculate based on the coordinate system you have set up, what are the coordinates of the extent of your specific graphics window view.

May I leave you to read https://wiki.geogebra.org/en/Corner_Command

and see example at https://www.geogebra.org/cl...


Regards,

lewws

photo
1

Thank you Lew for the reply, it really helps :)

photo
photo
2

zoomin is undependent for each axes so the general answer is not possible

if you want the zoom for xAxis you can do (x(Corner(5)) + 2) / 50 / x(Corner(3) - Corner(1))

photo
1

Thank you mathmajic for the reply,

The code works fine with me, but can you explain it please?

photo
3

Hi

In standard view, 1 unit of axe is 50 pixels

width of your window in pixels is x(Coin(5)) (not exactly because a corner is "on" the first or last pixel, so we have to add 1 pixel on the left and 1 pixel on the right)

photo
1

Thank you for the clarification

photo
photo
2

The goal is to calculate the distance of 2 points in (pixels if the x/y ratio not is 1/1)

This is possible with the formula in the attachment (I think)

--------------------------------------------------------------

But:

There is another question still unresolved for me:

How to draw a perpendicular to a path if the X/Y-ratio is not 1/1. The perpendicular should appear in 90° on the screen (that mean the angle look on the screen alway same, also when the X/Y-ratio is changed).

This is the prerequisite for determining the closestPointOnPath on the screen (not calculatet in GGB-units by GGB) between a path and a point when the X/Y ratio is not 1/1.

photo
1

espero que el adjunto se explique solo, aunque esté calculado en español

photo
1

Thank you very much mathmagic,

.

I think instead of Spanish, I'm going to learn the matrix calculus.

So I would be able to really appreciate your work.

And, maybe, then I might be able to create what I really want by myself.

------------------------------------------


Finally, I wanna:

I have a path c and a point P

I want the C=ClosestPoint(c,p) so that if the ratio XY is not 1:1, the picture on the screen looks like it is 1:1. So that Distance(C,D) in pixels (viewed on the screen) is the smallest possible value.

--------------------------------

story until now:

I wanted to reach this step by step. First with point and straight line.

I even achieved this (method TrailAndError). Only, unfortunately I don't understand why it works (if it does).

In the attachment my "solution" only to clarify what I am looking for.

And logically, with this not knowing, I do not reach the final goal (ClosestPointInPixel).

--------------------------------

I hope to formulate understandingly what I am looking for.

I would be pleased if you could support me in this task (of course with the "magic Spanish matrix", if possible).

--------------------------------

Note: I use deepL (mark a text anywhere (even inside GGB) and then double ctr-C-C) the translation is better than that of google.

photo
1

Thanks for ongoing discussion here.

Learning ideas and techniques from you both.

Thank you so much!

photo
1

un intento poco testado

Files: foro.ggb
photo
1

Thanks a lot mathmagic.

It works great.

I will still analyze your solution and try to understand the principle.

I intend to implement this code in this program (will take some time)

.

Best regards and thanks again

Raymond

photo
1

he estado testando y creo que es necesario cambiar la definicion del punto B definiendo B=corner(5)+(2,2)

así, cuando la ventana grafica está en standar view la matriz GP vale {{50,0},{0,-50}} que creo es lo correcto

photo
1

Yes, works also.

The change is plausible for me, because otherwise there must be (anywhere) a small difference.

I could not perceive this difference at any object with my eyes.

How did you find the differenze?

photo
photo
1

trying setaxesratio(100,1)

I got strange numbers in matrix

I was thinking about this in the first work but I though it was rounding problem. 100:1 shows it is not a rounding problem

photo
1

Thanks,

Oh, yes, I'll keep that in mind as a (general) control option.

photo
© 2020 International GeoGebra Institute