You are not logged in.

Fernando

Intermediate

  • "Fernando" started this thread

Posts: 222

Location: Habana, Cuba

Occupation: Architect, Photographer.

  • Send private message

1

Tuesday, May 19th 2020, 4:11am

Calculate hotspot polygonal length [SOLVED]

Hello, I need to obtain the length of a hotspot polygonal in units of measurement corresponding to the coordinates ATH ATV. That is to say that maintains the same value in any FOV.
Thanks,
Fernando

Note: polyline="true" (hotspot polygonal is a polyline)

This post has been edited 3 times, last edit by "Fernando" (May 22nd 2020, 5:16pm)


Sergey74

Intermediate

Posts: 172

Location: Russia, Chelyabinsk

Occupation: professional noob

  • Send private message

2

Tuesday, May 19th 2020, 9:45pm

If I understand you correctly

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  <hotspot name="polyspot"
           keep="false"
           visible="true"
           enabled="true"
           handcursor="true"
           capture="true"
           style=""
           alpha="1.0"
           polyline="true"
           fillcolor="0xAAAAAA"
           fillalpha="0.5"
           borderwidth="3.0"
           bordercolor="0xAAAAAA"
           borderalpha="1.0"
           subdiv="true"
           onover=""
           onhover=""
           onout=""
           ondown=""
           onup=""
           onclick=""
           onloaded=""
  >
      <point ath="-30" atv="30" />
      <point ath="30" atv="-30" />
  </hotspot>
  <action name="get_length" autorun="onstart">
    getlooktodistance(result, hotspot[polyspot].point[0].ath, hotspot[polyspot].point[0].atv, hotspot[polyspot].point[1].ath, hotspot[polyspot].point[1].atv);
    showlog();
    trace(result);
  </action>
translation difficulties *huh*

Fernando

Intermediate

  • "Fernando" started this thread

Posts: 222

Location: Habana, Cuba

Occupation: Architect, Photographer.

  • Send private message

3

Wednesday, May 20th 2020, 1:37am

Hi Sergey,

My pano is a plain image (as a map). I see that getlooktodistance get the spherical distance in degrees from 0 to 180 degree. I see that ATH and ATV are degrees too.

The polyline in a plain image is as a rute. I need to measure it for later to convert it to meters.

Perhaps I must set a reference maxime distance between two known points to 180 degree and then calculate the value from other angles.

Example:
180 degree it is equivalent to 500 meters, then 90 degree to 250 meters in the plain image.
I will test this idea. The final goal is to measure distances in meters from the values of ath, atv.

Thanks very much for your answer, I wait for your comments. *smile*

Sergey74

Intermediate

Posts: 172

Location: Russia, Chelyabinsk

Occupation: professional noob

  • Send private message

4

Wednesday, May 20th 2020, 6:13am

Oh, I get you! Experimenting at leisure. This is just trigonometry.
translation difficulties *huh*

5

Wednesday, May 20th 2020, 8:17am

Hi,

measurements would be only possible on a known flat surface.
Most easy on a 2d map, there just linearly get the distances between the polygon points.

Here an older example from a construction documentation - hover the lines with the mouse to see their length:
https://krpano.com/examples/map_line_measurement/

There this is done by calculating the length of the polylines and of one invisible 'scale'-line that has a known length.

Here the xml:
https://krpano.com/viewsource.html?examp…rement/tour.xml

and here the related actions:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<action name="calclength" scope="localonly">
    get_polyline_length('hs_4m_masstab', l_4m);
    get_polyline_length(get(caller.name), l_Xm);
    calc(caller.linelength_in_m, l_Xm * 4 / l_4m);
    roundval(caller.linelength_in_m, 1);
    calc(caller.linelength_in_m, caller.linelength_in_m + 'm');
</action>
    
<action name="get_polyline_length" scope="localonly" args="hsname, retvar">
    copy(pnts, global.hotspot[get(hsname)].point);
    def(totallength, number, 0);
    for(set(i,0), i LT (pnts.count - 1), inc(i),
      copy(p1, pnts[get(i)]);
      copy(p2, pnts[calc(i+1)]);
      calc(dx, p2.ath - p1.ath);
      calc(dy, p2.atv - p1.atv);
      calc(length, (dx*dx + dy*dy) ^ 0.5 );
      add(totallength, length);
    );
    parentscopeset(get(retvar), get(totallength));
</action>

Best regards,
Klaus

Sergey74

Intermediate

Posts: 172

Location: Russia, Chelyabinsk

Occupation: professional noob

  • Send private message

6

Wednesday, May 20th 2020, 8:58am

I’ll leave my example, too, it was not in vain that I spent time (mapscale calculated by known length)
https://panosphera.ru/gallery/ruler/

p.s. the accuracy of this method is not very high, because ... for a long time to explain
translation difficulties *huh*

Fernando

Intermediate

  • "Fernando" started this thread

Posts: 222

Location: Habana, Cuba

Occupation: Architect, Photographer.

  • Send private message

7

Wednesday, May 20th 2020, 3:15pm

Thank you very much, it is just what I needed!!!! I am going to study the example for adapting it to a very big image multires for my country *thumbsup*