Re: Scale a vector



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.

.



Relevant Pages

  • Re: Scale a vector
    ... The trasformation is like a zoom on images but I need on a vector. ... 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.TransformVectorsmethod to scale your vector. ...
    (microsoft.public.dotnet.languages.csharp)
  • Scale a vector
    ... 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. ...
    (microsoft.public.dotnet.languages.csharp)
  • Odd behavior of Swing components in a zoomable interface
    ... to the JPanel using XYConstraints--since they need to stay exactly ... label (a JComboBox), ... This works great when the zoom level is at 100%. ... being drawn in the new scale, but the editable part is still at the ...
    (comp.lang.java.gui)
  • Odd behavior of Swing components in a zoomable interface
    ... to the JPanel using XYConstraints--since they need to stay exactly ... label (a JComboBox), ... This works great when the zoom level is at 100%. ... being drawn in the new scale, but the editable part is still at the ...
    (comp.lang.java.programmer)
  • Re: Question about zoom values in Word 2004
    ... > have to zoom to a higher value to even get close to the scale of the ... The lazy programmers couldn't be bothered asking the machine how big ... Nothing like a few after dinner sums to help digest a fairly horrible ...
    (microsoft.public.mac.office.word)

Loading