3

I have trouble deciphering the individual parameters of the NURBS formula in the shapes NURBSTo entry (used for splines - curved edges). MS Visio documentation didn't help too much.

The number of parameters is variable depending on the complexity of the curve. A more simple example is:

NURBS(0.4492,3,0,1,0,-0.1875,0,1,1,-0.1875,0,1)

where I found out the start and end coordinate parameters start is 5th for X and 6th for Y. End is 9th for X and 10th for Y. But the Y coordinates are still wrong, so I suppose they should be combined with another parameter. This Java code provided the best results so far in getting the control points of the spline:

    int j = 0;

for (int i = 2; i + 4 < pointsS.length; i = i + 4)
{
    mxPoint currPoint = new mxPoint();
    currPoint.setX(startXY.getX() + (endXY.getX() - startXY.getX()) * pointsRaw[i + 2]);
    currPoint.setY(startXY.getY() - (endXY.getY() - startXY.getY()) * pointsRaw[i + 3]);
    pointList.add(currPoint);
    j++;
}

Just an example for a more complex spline:

NURBS(2.9857,3,1,1,0.1875,0,0,1,0.1875,-0.8954,0,1,0.1875,-1.3431,0,1,0.1875,-1.7908,0.4521,1,-0.4936,-1.7908,1.049,1,-1.1747,-1.7908,1.424,1,-1.1747,-2.1799,1.902,1,-1.1747,-2.5689,2.3742,1)

The documentation say for param 2 only "degree". I suppose it's the degree of the polynomial that is used for approximation.

The wiki page about NURBS: http://en.wikipedia.org/wiki/Non-uniform_rational_B-spline

Of course, it doesn't speak about Visio parameters :)

Mate E.
  • 396
  • 2
  • 10

2 Answers2

2

Are you accounting for the effect third and fourth parameters have on how you should interpret the x and y parameters?

From MSDN (http://msdn.microsoft.com/en-us/library/office/aa224197(v=office.11).aspx):

NURBS(knotLast, degree, xType, yType, x1, y1, knot1, weight1, ...)

knotLast The last knot.

degree The spline's degree.

xType Specifies how to interpret the x input data. If xType is 0, all x input data are interpreted as a percentage of Width. If xType is 1, all x input data are interpreted as local coordinates.

yType Specifies how to interpret the y input data. If yType is 0, all y input data are interpreted as a percentage of Height. If yType is 1, all y input data are interpreted as local coordinates.

x1 An x-coordinate.

y1 A y-coordinate.

knot1 A knot on the B-spline.

weight1 A weight on the B-spline.

Mike Woolf
  • 1,210
  • 7
  • 11
0

This may help: Visio 2003 Developer's Survival Pack by Graham Wideman

http://www.amazon.com/Visio-2003-Developers-Survival-Pack/dp/1412011124

There's an extensive section on Visio NURBS. It's only $7 for the Kindle edition.

saveenr
  • 8,439
  • 3
  • 19
  • 20