Welcome, Guest. Please login or register.

Author Topic: My Amos-vector question moved here  (Read 3409 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show all replies
    • http://www.troubled-mind.com
Re: My Amos-vector question moved here
« on: May 21, 2004, 01:56:56 PM »
If I were you I'd probably make a generalised function to do the Matrix math, and use it on your data.

I can't remember if AMOS handles functions properly or not though :-(

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show all replies
    • http://www.troubled-mind.com
Re: My Amos-vector question moved here
« Reply #1 on: May 21, 2004, 03:32:13 PM »
Quote

GreatLor wrote:
by 'generalised function' do you mean a a subroutine that takes input parameters (function) ? in that case, sure I know how to the most elegant and fast functions, but my question was if the actual vector rotations I do are THE way everyone did/do or not.


-
A function is a unit of code, that takes variables and returns a result. "Sin(x)" is an example of a fuinction.
-

I can't follow what you have done, there are far to many variables all over the place, if you turned it into a function then it would be easier to see...

If you used C (or even Blitz Basic) you could make a verctor data type that would add clarity to your code.

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show all replies
    • http://www.troubled-mind.com
Re: My Amos-vector question moved here
« Reply #2 on: May 21, 2004, 06:50:15 PM »
I was thinking that you could make a vector data type:

struct vector {
float x;
float y;
float z;
};

struct vector a;
struct vector b;
struct vector c;

int main() {
c=rot(a,b,1);
a=rot(b,c,2);
b=rot(c,a,3);

return 0;
};

vector rot(struct vector fist_vec , struct vector second_vec , int position) {

/* Do something to the two vectors*/

struct vector return_vec;

return_vec.x = first_vec.x * second_vec.x / position;


return return_vec;
};


I can't really see what you are trying to do though :-/ (as demonstrated by my random example). Whatever, data structures and function will make you code far easier to read and optimise than procedures and arrays.

Blitz Basic supports data types and functions, use that instead of AMOS.