Re: Scale a vector
- From: "Matteo Migliore" <matteo.migliore.cut@xxxxxxxxx>
- Date: Sun, 16 Sep 2007 16:36:48 +0200
Peter Duniho wrote:
Matteo Migliore wrote:Hi!
I've to scale a vector of numbers of size N to a vector of size M.
The trasformation is like a zoom on images but I need on a vector.
I'm not really clear on the exact meaning of your description; is "N"
and "M" the magnitude of the vector? Do you already know those
values, or do they need to be calculated as well? How many
dimensions does the vector have?
N is the size of the vector, M is the wanted size after the processing
of the new vector.
With vector I intend an array of int: int[] vector = new int[] { 10, 15, 17, 30, 200 };
In this case N = 5 and for example I need a new vector of size 8 that redistributes
the values. Think that is a line:
P1(1, 10) - P2(2, 15) - P3(3, 17) - P4(4, 30) - P5(5, 200)
I need a new line:
P1(1, ?) - P2(2, ?) - P3(3, ?) - P4(4, ?) - P5(5, ?) - P6(6, ?) - P7(7, ?) - P8(8, ?)
Or a new vector of 4 elements, or 3 etc...
Anyway, it seems to me that if you're just doing scaling, it would be
easiest to just write a simple method that does the work.
However, there is a Matrix class; if you already know M and N, and
your vector is a 2-dimensional vector, you could initialize a Matrix
instance with the scaling factor of M/N along the diagonal and then
use the Matrix.TransformVectors() method to scale your vector.
No, it's not a 2-dimensional vector, it's a 1-dimension vector. But can I use Matrix.TransformVectors() .
If the above doesn't help, maybe you could be more specific.
Pete
Thx a lot! ;-)
Matteo Migliore.
.
- Follow-Ups:
- Re: Scale a vector
- From: Peter Duniho
- Re: Scale a vector
- References:
- Scale a vector
- From: Matteo Migliore
- Re: Scale a vector
- From: Peter Duniho
- Scale a vector
- Prev by Date: Re: Popup Dialog Position
- Next by Date: Re: Problems Handling Errors Correctly
- Previous by thread: Re: Scale a vector
- Next by thread: Re: Scale a vector
- Index(es):
Relevant Pages
|
Loading