Discussion Groups

Robot Structural Analysis

Reply
Valued Contributor
mgaafar
Posts: 86
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: 86
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: 4,935
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: 331
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: 4,935
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: 198
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: 198
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.