Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: krpano.com Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

1

Sonntag, 17. Dezember 2017, 21:16

Hotspot getcenter wrong result

Hi Klaus

Can you please improve get center function to give more precised results, please? *love* When working on big Flat where high precision is needed (doing polygonal area calculation) there seams to be some internal rounding in the Krpano making result with just small offset to real result.

Test with simple 4 point poli hotspot:

Quellcode

1
2
3
4
5
6
<hotspot name="test" keep="true" ath="0" atv="0" align="center" edge="center" fillcolor="123456" fillalpha="0.9" borderwidth="2" bordercolor="123456"> 
<point ath="-0.2" atv="0.2"/>
<point ath="0.30" atv="0.20"/>
<point ath="0.30" atv="-0.20"/>
<point ath="-0.20" atv="-0.20"/>		
</hotspot>


Result is:
ath= 0.05000000000001137
atv= 0

It should be: 0.05 and 0.

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Umalo« (18. Dezember 2017, 13:44)


Beiträge: 674

Wohnort: Poland, Europe

Beruf: krpano developer : virtual tours : VR solutions

  • Nachricht senden

2

Montag, 18. Dezember 2017, 12:19

The reason is IEEE 754

I use roundval in this case. I know that there are different methods in a clean JS, but it seems to me that Math.round(num) is better than num.toFixed(0);. I think roundval is enough.

Kind regards
Piotr
»spacerywirtualne« hat folgendes Bild angehängt:
  • IEEE.png
Pawel & Piotr

Virtual Tour Builder new HTML5 IDE Virtual Tours builder - free modern templates, POI system and Livepano Assistance and multi Floorplans

HTML5-VR Audio Plugin

New Lensflare Plugin for Flash, HTML5, WebVR!

3

Montag, 18. Dezember 2017, 13:08

I use roundval in this case.
Thanks for your try but it is other way around. I need not rounded result as I work with huge Flat pano. We know that ath and atv values there are very smll so I need as precised NOT rounded result. As part of the code I also display selected area rounding would make mistakes. So I need correct (as possible) result in first place. If I would work on sphere system then this rounding would be used.
Waiting for Klaus opiniion if he can come up with something.

4

Montag, 18. Dezember 2017, 13:34

@umalo

hotspot[test].getcenter(ath,atv);
roundval(ath, 3);
roundval(atv, 3);

if you want more precision, use 4 or 5

5

Montag, 18. Dezember 2017, 13:46

Seams headline was misleading you in direction of seeking for rounding solution while I was pointing to offset in real center vs krpano calculated.
Changed headline to Wrong result.
Thanks anyway.

Beiträge: 674

Wohnort: Poland, Europe

Beruf: krpano developer : virtual tours : VR solutions

  • Nachricht senden

6

Montag, 18. Dezember 2017, 15:14

You're right Umalo. In gigapanoramas, the precision is very important and crucial.

Kind regards
Piotr
Pawel & Piotr

Virtual Tour Builder new HTML5 IDE Virtual Tours builder - free modern templates, POI system and Livepano Assistance and multi Floorplans

HTML5-VR Audio Plugin

New Lensflare Plugin for Flash, HTML5, WebVR!

7

Montag, 18. Dezember 2017, 19:34

you should clarify what you want...

Zitat

Result is:
ath= 0.05000000000001137

i dont understand it ... this is the result of what?

Beiträge: 639

Wohnort: Sevastopol, Crimea, Russian Federation

Beruf: Interpreting, Building virtual tours

  • Nachricht senden

8

Dienstag, 19. Dezember 2017, 07:30

Hi)

Umalo wants more precise result of getcenter function fot the hotspots https://krpano.com/docu/xml/#hotspot.getcenter

Correcte me, if I misunderstood something (sorry then, Umalo). ;-)
Regards,

Alexey

9

Dienstag, 19. Dezember 2017, 10:01

Hi,

there is no rounding here, but getcenter doesn't return the average of the ath/atv values.

First the ath/atv values will be converted to 3d vectors, then these 3d vectors will be averaged and then the resulting 3d vector will be converted back to the 'center' ath/atv value. So the result can be different to an averaging of the ath/atv values.

But I don't understand where the problem here is, even with very large gigapixel panos, that point should be in the in 'center/middle' of the polygon, the precising will be never intentional reduced...

Best regards,
Klaus

10

Dienstag, 19. Dezember 2017, 14:39

Simple use case I posted in my first post with 4 points is giving center that has offset to real center.
Real center should be: ath= 0.05000000000000000 Krpano gives ath= 0.05000000000001137 for center.
Do you really need to go in sphere to coordinate conversions as simple sum of ath divided by number of points gives correct ath as center? If we do the same for atv result should be exact. Or?
I have project where I am calculating area of selected object using polygonal hotspots. I place result in center of the polygonal hotspot which is visually never real hotspot center. Then I went into simple posted use case to see if result from Krpano center is correct and I see it is not. Before going into doing calculations of center on my own wanted to check with you if you see some bug in Krpano calculations there what you can fix for next versions.

11

Samstag, 23. Dezember 2017, 22:40

Hi Klaus


See what I am getting when placing result at hotspot center. This is how I came to testing more to see if my code is wrong or Krpano Hotspot getcenter.

12

Donnerstag, 28. Dezember 2017, 15:51

Hi,

okay, the hotspot getcenter function might be too simple for this case - it calculates only the average of the <point> coordinates...

Check if there are no double-points (e.g. the same point for the start and end of the polygon), because these would shift the center point.

For generally visually better results more complex algorithm would be required - e.g. something like this by finding the largest fitting circle:
https://arxiv.org/ftp/arxiv/papers/1212/1212.3193.pdf

Best regards,
Klaus

13

Donnerstag, 28. Dezember 2017, 18:05

Thanks for hint but this is not the case. Now I made my own calculator of the center and result is different to what Krpano is giving. I still think you are calculating average of the <point> coordinates where due to work with huge number of decimal points (maybe also floating point as suggested by @spacerywirtualne) there is offset to expected result.
What I did is first calculate sum of all points ATH. Then dividing it with number of points. And then first time making spheretoscreen conversion. I got this as result which tells me you could do the same in your get center calc internally. For me this point is solved but if you like to improve this for some other users addressing same issue in the future.

Result with my center calculator: