Discussion Groups

Robot Structural Analysis

Reply
Valued Contributor
mgaafar
Posts: 107
Registered: ‎11-29-2011

Re: Rounding up coordinates (API)

04-08-2013 10:11 AM in reply to: Rafal.Gaweda

here you are

Please use plain text.
Valued Contributor
mgaafar
Posts: 107
Registered: ‎11-29-2011

Re: Rounding up coordinates (API)

04-08-2013 03:14 PM in reply to: mgaafar

Maybe this link can help figuring out the approximation error.

http://www.theregister.co.uk/2006/08/12/floating_point_approximation/

 

Please use plain text.
Product Support
Rafal.Gaweda
Posts: 5,293
Registered: ‎04-26-2010

Re: Rounding up coordinates (API)

04-09-2013 12:13 AM in reply to: mgaafar

More less this wqas the problem

According to our processors 10.21*100000 = 1021000,00000001

 

Correction in attachment



Rafal Gaweda
Please use plain text.
Valued Mentor
t.sautier
Posts: 433
Registered: ‎12-14-2012

Re: Rounding up coordinates (API)

04-09-2013 12:17 AM in reply to: Rafal.Gaweda

Can you post the .exe file please ..;

Thanks a lot.

I am not familiar with  Csharp express etc ..

 

 

Please use plain text.
Product Support
Rafal.Gaweda
Posts: 5,293
Registered: ‎04-26-2010

Re: Rounding up coordinates (API)

04-09-2013 12:20 AM in reply to: t.sautier

It was wrong attachement.

Check again attachment in previous message.

 

You are fast :-) It took me one minute to replace attachment and in the mean time you downloaded it.



Rafal Gaweda
Please use plain text.
Distinguished Contributor
mirko.jurcevic
Posts: 215
Registered: ‎01-12-2013

Re: Rounding up coordinates (API)

01-10-2014 03:54 AM in reply to: Rafal.Gaweda

This add-in is awesome! 

Saves a lot of time with sloppy users :smileywink:

INTELIKA

Mirko Jurcevic M.Eng.
INTELIKA d.o.o.
www.intelika.hr
Please use plain text.
Distinguished Contributor
mirko.jurcevic
Posts: 215
Registered: ‎01-12-2013

Re: Rounding up coordinates (API)

01-10-2014 05:40 AM in reply to: Rafal.Gaweda

I wanted to round to 0,05m so I had to make some changes to your code (to ToDec function), if you don't mind.

 

Maybe you're interested:

private double ToDec(double numberToTruncate)
{
double roundingVal = 1;
int numOfDecimals = 0;

	if (TolcomboBox.SelectedItem != null) {
		string text = TolcomboBox.SelectedItem.ToString();
		if (text.Length > 1) numOfDecimals = text.Length - 2;
		roundingVal = Convert.ToDouble(text);			
	}
						
        numberToTruncate = Math.Round(numberToTruncate, 9);

	double power = Math.Pow(10.0, (double)numOfDecimals);

        if (radioButton1.Checked)
        {
	return Math.Round(Math.Floor(numberToTruncate / roundingVal) * power, 0) * roundingVal / power;
        }
        else
        {
	return Math.Round(Math.Ceiling(numberToTruncate / roundingVal) * power, 0) * roundingVal / power;
        }
}

Function now can be used to round to any decimal value, for example: 0,25  :smileywink:

 

Cheers!

INTELIKA

Mirko Jurcevic M.Eng.
INTELIKA d.o.o.
www.intelika.hr
Please use plain text.
Member
janis_mr
Posts: 4
Registered: ‎04-30-2012

Re: Rounding up coordinates (API)

08-10-2014 11:37 PM in reply to: mirko.jurcevic

Hi Mirko,

Do you have an exe file for your modified version of this code?

Would be greate to have it..

 

Thanks

Regards

Janis

Please use plain text.
Distinguished Contributor
mirko.jurcevic
Posts: 215
Registered: ‎01-12-2013

Re: Rounding up coordinates (API)

08-15-2014 04:22 AM in reply to: janis_mr

Of course

Here, just change the extension to exe and add it to robot

 

Right click on the link and "save link as"

INTELIKA

Mirko Jurcevic M.Eng.
INTELIKA d.o.o.
www.intelika.hr
Please use plain text.
Member
janis_mr
Posts: 4
Registered: ‎04-30-2012

Re: Rounding up coordinates (API)

08-15-2014 04:31 AM in reply to: mirko.jurcevic

Thats great. Thanks a lot!

 

Regards

Janis

Please use plain text.