473,386 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Splines with shared knot vectors

Hi all,

This is going to be more about design issues and might get rather long,
but I was hoping some of you might have some input on this. I'm using
splines to model two-dimensional parametric curves (x(t),y(t)) to
interpolate between nodes. I have a working Spline class that does
cubic spline interpolation of function values f[i] that are defined at
knot positions t[i]. I use this in my current Curve class. Along with
the splines for x and y, the Curva class also has one for any other
values (say p and q) that need to be interpolated along the curve. All
Splines x, y, p and q currently have their own knot vector t[i] and the
Curve class provides functions that ensure a certain t[i] of all
splines only get changed all at once (in my app the t[i] sometimes need
to change to enhance the parameter mapping of the curve). The logical
next step would be, to change the spline class so it supports sharing a
knot vector between splines - it will save storage and will guarantee
all Splines stay in sync. Also, I expect subclasses of curve to add
more interpolation variables, which will also be easier handled if it
is possible to just attach the new spline to the existing knot vector.
I think I will be able to figure out a way to handle this neatly, most
likely using smart pointers with reference counting.

Now for my dilemma: my current spline class supports a public member
mySpline.Add(t_new, f_new) to add a new interpolation value at the end
(t_new > max(t[i])), so splines can be built one point at a time.
Similarly, the curve class supports myCurve.Add(t_new,
x_new,y_new,p_new,q_new) and will just add the new data to the
corresponding spline. This also provides an interface to build the
curve one point at a time. I still want to provide this functionality
in the new spline class (with the shared knot vector) and obviously
retain it for the Curve class. But what should the behaviour of
mySpline.Add(...) be if mySpline uses a shared knot vector? Ideally,

x.Add(t_new, x_new); y.Add(t_new, y_new);

probably should behave the same, whether x and y share a knot vector or
just have a knot vector with equal values. However,

x.Add(t_new, x_new); y.Add(t_alternate, y_new);

probably should generate an error when the knot vectors are shared. I
imagine further that any spline that share a knot vector that is not
explicitly expanded gets expanded with a default value - or it might be
better to require all splines to be given a new value explicitely
before more points can be added.

So my question is, how can I get at such a mechanism? I assume the knot
vector object should keep track of which associated splines have been
updated and which not, but I can't get at a good mechanism to do so. Or
am I just going at this the wrong way? I hope you can give me some
ideas, thanks in advance,

best regards Mark

Jul 23 '05 #1
2 1798
Mark Stijnman wrote:
[...splines sharing a vector of knots and built one point at a time...]
So my question is, how can I get at such a mechanism? I assume the knot
vector object should keep track of which associated splines have been
updated and which not, but I can't get at a good mechanism to do so. Or
am I just going at this the wrong way? I hope you can give me some
ideas, thanks in advance,


Make a separate class -- knotvector. Make your spline class to have
a pointer to a knotvector (it's called "association"). That would allow
you to share knotvectors between instances of splines. I imagine that
not all instances of the spline need to have the same knotvector, but
some may.

You should probably think a bit more about the functionality of your
system. You say that the knot vector should have a list of splines it is
associated with. I am not sure about that. If you update one of the
splines that share a knot vector and *never* update the other splines with
the same knot vector, what then? I imagine that "breaking off" one of the
splines from the set by cloning and changing its knot vector is not out of
the realm of possibilities. IOW, they share a knot vector until one of
the splines needs a different knot vector. In that case that one spline
"breaks off" with its own, now unique, knot vector. It's like "copy on
write" sort of thing.

This is marginally a language question. Try the comp.object newsgroup and
the comp.graphics.algorithms as well.

V
Jul 23 '05 #2
Victor Bazarov wrote:
Mark Stijnman wrote:
[...splines sharing a vector of knots and built one point at a time...] So my question is, how can I get at such a mechanism? I assume the knot vector object should keep track of which associated splines have been updated and which not, but I can't get at a good mechanism to do so. Or am I just going at this the wrong way? I hope you can give me some
ideas, thanks in advance,
Make a separate class -- knotvector. Make your spline class to have
a pointer to a knotvector (it's called "association"). That would

allow you to share knotvectors between instances of splines. I imagine that not all instances of the spline need to have the same knotvector, but
some may.
That was the plan indeed.
You should probably think a bit more about the functionality of your
system. You say that the knot vector should have a list of splines it is associated with. I am not sure about that. If you update one of the
splines that share a knot vector and *never* update the other splines with the same knot vector, what then?
Actually, changes to the knot vector render the interpolation data
useless, so the spline objects need to be notified of the change. And
about never updating the others, that's really where the trouble is
indeed.
I imagine that "breaking off" one of the
splines from the set by cloning and changing its knot vector is not out of the realm of possibilities. IOW, they share a knot vector until one of the splines needs a different knot vector. In that case that one spline "breaks off" with its own, now unique, knot vector. It's like "copy on write" sort of thing.
That might be something one would want the spline class to support,
yes. I'm still not fully convinced I'm doing the right thing by
performing the 'optimization' of allowing shared knot vectors in the
first place though, I'm still considering options.
This is marginally a language question. Try the comp.object newsgroup and the comp.graphics.algorithms as well.

V


You are probably right, I'll have a look at comp.object. Thanks for the
response though :)

grtz Mark

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Pratyush | last post by:
Hi, Suppose there is a vector of objects of class A, i.e., std::vector<A> vec_A(N); The class A satisifies all the STL vector requirements. Now I wish to add some attributes for each of the...
0
by: keppus | last post by:
Who can help me? I need an xquery expression that extract the knot especially the pat of that knot !! When I query my db with an textretrieval I always get the whol XML-Doc, but I only want...
5
by: Computer Whizz | last post by:
I was reading through Accelerated C++ at work when I read through the first mention of Vectors, giving us certain functions etc. Is there any benefit of Arrays over Vectors? Since all Vectors...
3
by: Amit | last post by:
Hello. I am having some problem organizing a set of vectors. The vectors itself, could contain a pointer( say integer pointer) or could contain another object MyClass. 1>So, first of all, is...
4
by: Dr. J.K. Becker | last post by:
Hi all, I have vectors that holds pointers to other vectors, like so: vector<whatever> x; vector<whatever*> z; z=&x; Now I add something to x
5
by: madhu | last post by:
http://msdn2.microsoft.com/en-us/library/fs5a18ce(VS.80).aspx vector <intv1; v1.push_back( 10 ); //adds 10 to the tail v1.push_back( 20 ); //adds 20 to the tail cout << "The size of v1 is " <<...
2
by: wuzertheloser | last post by:
Use the program skeleton below (starting with #include <stdio.h>) as the starting point for quiz4. Add the necessary code to the functions prob1() and prob2(), and add the other 2 functions, as...
1
by: grbCPPUsr | last post by:
How can we create C++ STL containers, like hash map, vectors, etc in shared memory and make then accessible to two or more different, unrelated processes? Can somebody please help me? I saw...
1
by: Rob | last post by:
How would I do this? I want to be able to handle vectors of many different types of data and vectors that can contain any number of other vectors of data. Currently, I have a templated...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.