Recent

Author Topic: matrix unit  (Read 7308 times)

HappyLarry

  • Full Member
  • ***
  • Posts: 155
matrix unit
« on: April 26, 2015, 12:07:41 pm »
How do you show the result when you multiply a 2x2 matrix by a 1x2 vector using the matrix unit?

Code: [Select]
program project1;

uses
  Classes, matrix;

var
  M:TMatrix2_double;
  V1,V2:TVector2_double;

begin
  writeln('---Matrices---');
  //M:=TMatrix_double.create;
  M.init(1,2,3,4);
  V1.init(5,6);
  V2:=M*V1;
  //How do I show the answer?

  writeln('----done------');
  readln;
end.
 
Use Lazarus and Free Pascal and stand on the shoulders of giants . . . very generous giants. Thank you.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me

HappyLarry

  • Full Member
  • ***
  • Posts: 155
Re: matrix unit
« Reply #2 on: April 26, 2015, 04:20:47 pm »
Thanks Leledumbo - I have edited my code. It gives the correct  answer of
17
39

Code: [Select]
program project1;

uses
  Classes, matrix;

var
  M:TMatrix2_double;
  V1,V2:TVector2_double;

begin
  writeln('---Matrices---');
  M.init(1,2,3,4);
  V1.init(5,6);
  V2:=M*V1;
  writeln(V2.data[0]:8:0);
  writeln(V2.data[1]:8:0);[
  writeln('----done------');
  readln;
end.

The information in TMatrix really does need some easy examples to make things clearer.
Use Lazarus and Free Pascal and stand on the shoulders of giants . . . very generous giants. Thank you.

 

TinyPortal © 2005-2018