You are not logged in.

jeromebg

Professional

  • "jeromebg" started this thread

Posts: 1,120

Location: Angers - France

Occupation: 360 experiences creator

  • Send private message

1

Monday, March 15th 2021, 7:23pm

getlooktodistance for 3D hotspots ?

Hi ,
Is there a similar getlooktodistance action for 3D positioned hotspots (tx,ty,tz) ?
Thanx !

jeromebg

Professional

  • "jeromebg" started this thread

Posts: 1,120

Location: Angers - France

Occupation: 360 experiences creator

  • Send private message

2

Tuesday, March 16th 2021, 9:07am

var a = x2 - x1;
var b = y2 - y1;
var c = z2 - z1;
var d= Math.sqrt(a * a + b * b + c * c);

should work to get distance between 2 3D hotspots.

This post has been edited 1 times, last edit by "jeromebg" (Mar 18th 2021, 9:19am)


Tuur

Sage

Posts: 3,839

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

3

Friday, March 19th 2021, 12:05am

Hi,

not fully sure, but i think the below is already doing the horizontal part quite good.
Busy with something else.
if there is a better way of doing this please share.

https://www.virtualtuur.com/krpano/120/h…odistance_3d/1/

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
	<events name="bla" keep="true" onviewchange="3d_hotspots_in_range();" />
	<action name="3d_hotspots_in_range" protect="true">
		adjusthlookat(0);
		calc(vty1, view.tz);
		calc(vtx1, view.tx);
	
		for(set(i,0), i LT hotspot.count, inc(i), 
			calc(vty2, hotspot[get(i)].tz);
			calc(vtx2, hotspot[get(i)].tx);
			calc(phh1, (vty2 - vty1) / (vtx2 - vtx1));

			Math.atan(_rads, phh1);
			calc(_degs, _rads * (180 / Math.PI));
		
			if(view.hlookat GE 0,
				calc(hotspot[get(i)].pseudoath,  90 - _degs);
			,
				calc(hotspot[get(i)].pseudoath, -90 - _degs);
			);
		
			getlooktodistance(d, hotspot[get(i)].pseudoath, 0);
		
			if(d LT 10,  
					set(hotspot[get(i)].bgcolor, 0x00ff00);
			, 
					set(hotspot[get(i)].bgcolor, 0xff0000);
			); 
		);
	</action>


Tuur *thumbsup*

jeromebg

Professional

  • "jeromebg" started this thread

Posts: 1,120

Location: Angers - France

Occupation: 360 experiences creator

  • Send private message

4

Friday, March 19th 2021, 9:12am

Thanx Tuur, but the formula I mentioned works perfectly ;)

https://www.360images.fr/barebone_getdistance_3d/

Source code

1
2
3
4
5
6
7
<action name="get_3d_distance" scope="local">
calc(x,caller.tx - view.tx);
calc(y,caller.ty - view.ty);
calc(z,caller.tz - view.tz);
calc(d,sqrt(x*x + y*y + z*z));
...
</action>

Tuur

Sage

Posts: 3,839

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

5

Friday, March 19th 2021, 4:16pm

Hah!
Nice.

Different use, different math.
Thanks for sharing!
Tuur *thumbsup*

jeromebg

Professional

  • "jeromebg" started this thread

Posts: 1,120

Location: Angers - France

Occupation: 360 experiences creator

  • Send private message

6

Saturday, March 20th 2021, 10:38am

Same use, different maths ;)
https://www.360images.fr/barebone_getdistance_3d_tuur/

By the way your example seems to be false, if you pan around then d value is changing.

Tuur

Sage

Posts: 3,839

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

7

Saturday, March 20th 2021, 11:24am

hi,

no!
not same use at all.

Quoted

By the way your example seems to be false, if you pan around then d value is changing.

https://krpano.com/docu/actions/#getlooktodistance

well, besides i am very bad in math, i also just did a very quick try.
As said, busy with something else.
I was also not measuring the distance, this was not clear for me in your first post and tread title.
I was just trying to make the hotspots green when they come into 'range' with hlookat.
So i thought maybe make a pseudo ath for the 3d positioned hotspots.
Totally different approach and use.
I think both are interesting though... also to combine.
I hope to also see good solution for my approach.(better and complete math perhaps)
I'll work a bit on the atv .. later..

Tuur *thumbsup*

This post has been edited 1 times, last edit by "Tuur" (Mar 20th 2021, 5:27pm)