How to get the exact position of a shape using regular API?

Typically: "How do I... ", "How can I... " questions
Post Reply
suri
Posts: 42
Joined: 07 Apr 2020, 17:24

How to get the exact position of a shape using regular API?

Post by suri »

Hallo Admin,

I need to get the exact position of a shape using regular API. I did not find an API which does exactly what I need!.

I used sim.getOjectPosition(ShapeHandle,-1). But using this API I got the position of blue line in the below image. Kindly have a look.
Image

But I need the position at intersection of green and red line. How can I know what position difference is there between blue(position got from co-ordinate frame) and red line, so then I can add extra difference to linear.x value manually?

In other words, middle position of intersection of two shapes in the above figure.

Basically blue line is the co-ordinate system of that shape, I am assuming it and also position of that shape relative to world frame!

Or else any suggestion to do it in a better way in coppeliasim?

Never mind for my understanding in co-ordinate system.

Thanks in advance.

coppelia
Site Admin
Posts: 10364
Joined: 14 Dec 2012, 00:25

Re: How to get the exact position of a shape using regular API?

Post by coppelia »

Hello,

not sure what the blue line represents... or the red and green line in that picture.

The reference frame of a shape is always located in the middle of that shape. If you know the extent of the shape, then you can figure out other coordinates on your shape. You can always use a ray-type proximity sensor to figure out the intersection position between the sensor and a particular shape if needed.

Cheers

suri
Posts: 42
Joined: 07 Apr 2020, 17:24

Re: How to get the exact position of a shape using regular API?

Post by suri »

Thanks you so much. I solved the problem with your suggestion/solution.

Post Reply