How to define a point on the surface of a cylinder?

Typically: "How do I... ", "How can I... " questions
Post Reply
jianye
Posts: 46
Joined: 16 Oct 2019, 13:58

How to define a point on the surface of a cylinder?

Post by jianye »

hello,

I'm trying to calculate the distance between two objects. Generally, I use the smallest distance function to measure two objects.
But in my project https://ibb.co/t2yTTJ1, when the person model goes along the path and when the cylinder is between the robot(UR10) and person model, I want to define a point on the surface of the cylinder and measure the distance between robot and cylinder(defined point) and the distance between the person and cylinder(point).

But I don't whether there is a way to define the point on the cylinder or other shape?

Best regards,

Jian

fferri
Posts: 1227
Joined: 09 Sep 2013, 19:28

Re: How to define a point on the surface of a cylinder?

Post by fferri »

The distance calculation module can compute distance between a cylinder and a dummy. Just make sure the measurable property is turned on.

To define a point on a cylinder of radius \(r\) and height \(h\) you can use the formula \(\hat x r cos \theta + \hat y r sin \theta + \hat z h \lambda\) where \(\lambda\) and \(\theta\) are two parameters, and \(\hat x\), \(\hat y\), \(\hat z\) are the normal vectors of its rotation matrix. You can simply place a dummy at coordinates \(\left( r cos \theta, r sin \theta, h \lambda \right)\) relative to the cylinder and that is your point.

jianye
Posts: 46
Joined: 16 Oct 2019, 13:58

Re: How to define a point on the surface of a cylinder?

Post by jianye »

Thanks for your reply.

I want to know, is there a method to define a point on the surface of an obejct with any shape, not only cylinder?

thanks,

Jian

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

Re: How to define a point on the surface of a cylinder?

Post by coppelia »

Simply create a dummy (sim.createDummy), and place it where you want (sim.setObjectPosition), then attach it to the shape (sim.setObjectParent). To find the coordinate on the surface of a shape where to place the dummy, you can use a proximity sensor for instance (e.g. a ray-type proximity sensor). Then use sim.checkProximitySensor.

Cheers

Post Reply