SBIO Cluster Demo

Crank Storyboard Designer samples and code snippets.

Moderator: jamiev

SBIO Cluster Demo

Postby atinir » Wed Mar 08, 2017 12:57 pm

Hi,

In the sample SBIO Cluster Demo
SBIO_Cluster_Demo.jpg
SBIO_Cluster_Demo.jpg (53.48 KiB) Viewed 332 times
is it possible to get the x,y position of the red arrow(image pointer_speedometer2.png) that is moving. This image Is located in control pointer_speedometer .

With this code I get the angle

local data = {}
data=gre.get_data("speedometer.pointer_speedometer.rot")
print("Arrow X"..data1["speedometer.pointer_speedometer.rot"])

In the properties of the control there is a position x=140 and y=0. It seems they are fixed. I need the x,y position of red arrow as it moves.

Thank you :)

All the best,
Atinir
atinir
 
Posts: 25
Joined: Thu Apr 21, 2016 9:20 am

Re: SBIO Cluster Demo

Postby mlove » Fri Mar 17, 2017 12:32 pm

Hi,

That sample doesn't change the x and y position of the image render extension. What is happening is the image is being rotated around a point in the center of the control. The exact x and y position for where that image is rendered isn't available, this is calculated during the rendering of the image render extension. Is there a particular reason you need these coordinates?

Regards,

Matt L
mlove
 
Posts: 18
Joined: Tue Apr 17, 2012 1:26 pm

Re: SBIO Cluster Demo

Postby atinir » Wed Mar 22, 2017 4:29 am

Hi Matt,

Thank you for your reply. Yes, I really need the x,y position of the tip of the arrow because I need to track how the arrow position changes.

In order to solve this, since I always can get the angle of rotation, I used this angle and trigonometric functions to find x,y position.
This mathematical manipulation worked for me.


local redArrowAngle=gre.get_data("ArrowLayer.redArrowTop.rot")
local redArrowRadian=math.rad(redArrowAngle["ArrowLayer.redArrowTop.rot"])
local redArrowHeight =gre.get_control_attrs("ArrowLayer.redArrowTop","height")
local redArrowWidth =gre.get_control_attrs("ArrowLayer.redArrowTop","width")
local redArrowControlX, redArrowControlY
local pointer_speedometer2Height =111
r=(redArrowHeight["height"]/2-pointer_speedometer2Height)+pointer_speedometer2Height/2
b=math.sin(redArrowRadian)*r
a=math.cos(redArrowRadian)*r
redArrowX=redArrowWidth["width"]/2+b+redArrowControlX["x"]
redArrowY=redArrowHeight["height"]/2-a+redArrowControlY["y"]

Best,
Atinir
atinir
 
Posts: 25
Joined: Thu Apr 21, 2016 9:20 am


Return to Samples

Who is online

Users browsing this forum: No registered users and 1 guest