Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Vector Multiplication
Vector Multiplication
2004-04-02, 10:43 PM #1
Hi!
I'm making a COG where when I enter a room, alot of objects are created in a row. Now, I've put together a little loop that will do that, only I'm not sure about the math or how to gonvert it into vectors...
temp0[j]=CreateThingAtPos(object,GetThingSector(origin),VectorAdd(GetThingPos(origin),(dir*distance)*j),GetThingLVec(origin));

Temp0-100: wish to catch the object so I can take it away when I leave.
Origin: Center point thing.
dir: A vector indicating in which way the row will be created.
distance: A flex that indicates how big the object is and how far apart the centers should be from each other.
j: An int that is in the loop.
for(j=0; j<amount of object in a row; j=j+1)

I think you see what I want. How to make the flex and ints become vectors so I can add?

/Edward
Edward's Cognative Hazards
2004-04-04, 5:18 PM #2
I see what your getting at, I dont know much about how to do it, but to help you out at my most, to make it easier to find which vectors work for where....
-------------------------------------------
STRAIGHT VECTORS:
-------------------------------------------

Straight up (grid)
------------------
(0.00/1.00/0.00)

Straight Down (grid)
--------------------
(0.00/-1.00/0.00)

Right (grid)
------------
(1.00/0.00/0.00)

Left (grid)
-----------
(-1.00/.00/0.00)

Down (as if a fall)
-------------------
(0.00/0.00/-1.00)

Up (as if a rise)
-----------------
(0.00/0.00/1.00)

-------------------------------------------
45 DEGREE ANGLE VECTORS:
-------------------------------------------

45 to the RIGHT (grid)
----------------------
(0.71/0.71/0.00)

135 to the RIGHT (grid)
-----------------------
(0.71/-0.71/0.00)

45 to the LEFT (grid)
---------------------
(-0.71/0.71/0.00)

135 to the LEFT (grid)
----------------------
(-0.71/-0.71/0.00)

Foreward-Diag.Up
----------------
(0.00/0.71/0.71)

Foreward-Diag.Down
------------------
(0.00/0.71/-0.71)

Backward-Diag.Up
----------------
(0.00/-0.71/0.71)

Backward-Diag.Down
------------------
(0.00/-0.71/-0.71)

Left-Diag.Up
------------
(-0.71/0.00/0.71)

Left-Diag.Down
--------------
(-0.71/0.00/-0.71)

Right-Diag.Up
---------------
(0.71/0.00/0.71)

Right-Diag.Down
-------------
(0.71/0.00/-0.71)

Thats all the info i can give you. Good Luck!

------------------
Your Owners Clan Leaader,
_yo_wasup_
-=__/¯¯l¤¥Ø¤l¯¯\__\/\/ª≤uÞ_=-
http://www.TeamYo.org
2004-04-05, 4:01 AM #3
No, no... You don't see... I'm trying to multiply vectors. This is what I've gotten it to:

vector dir=(0/1/0)
flex distance=1.4
int amount=12

for(j=0; j<amount; j=j+1)
temp0[j]=CreateThingAtPos(object,GetThingSector(origin),VectorAdd(GetThingPos(origin),(dir*VectorSet(distance,distance,distance))*VectorSet(j,j,j)),GetThingLVec(origin));

Now, I put it through Parsec and it said that Vector expected, but int, flaot, flex operator found. My guess is the *. Is there any VectorMulti() or any way I can multiply them together?

/Edward
Edward's Cognative Hazards
2004-04-05, 1:29 PM #4
Try using this. I think I have an idea of what you're saying now, but I don't know if this is what you want or not.
newVec = VectorSet(VectorX(vec1)*VectorX(vec2), VectorY(vec1)*VectorY(vec2), VectorZ(vec1)*VectorZ(vec2));

------------------
Bond, Power, CA, The Force, Saber, IC, Epic, Oily Mexican Food, BG, /\ |> /\ /\/\, Sentences.
Now you know where I've been.

[This message has been edited by Darth Slaw (edited April 05, 2004).]
May the mass times acceleration be with you.
2004-04-06, 12:16 PM #5
Ah, thank you for that. All seems to be well. Now, a small problem...
Code:
# Creates Objects when you enter.
#
# By Edward
flags=0x240
symbols

message		entered
message		startup

sector		enter0
sector		enter1
sector		enter2
sector		enter3
sector		exit0
sector		exit1
sector		exit2
sector		exit3

thing		origin

flex		distance
int		amount

thing		temp0		local
thing		temp1		local
...
thing		temp100		local

int		i		local

int		j		local

vector		dir

vector		vec1		local
vector		vec2		local

template	object

end
#
code
startup:
	for(j=0; j<101; j=j+1) temp0[j]=-1;
return;
entered:
	for(i=0; i<4; i=i+1)
	{
		if(GetSenderRef()==enter0)
		{
			for(j=0; j<amount; j=j+1)
			{
				vec1=VectorSet(VectorX(dir)*distance,VectorY(dir)*distance,VectorZ(dir)*distance);
				vec2=VectorSet(j,j,j);
				temp0[j]=CreateThingAtPos(object,GetThingSector(origin),VectorAdd(GetThingPos(origin),(VectorSet(VectorX(vec1)*VectorX(vec2), VectorY(vec1)*VectorY(vec2), VectorZ(vec1)*VectorZ(vec2)))),GetThingLVec(origin));
				CaptureThing(temp0[j]);
			}
		}
		else if(GetSenderRef()==exit0)
		{
			for(j=0; j<101; j=j+1)
			{
				if(temp0[j]!=-1) DestroyThing(temp0[j]);
				temp0[j]=-1;
			}
		}
	}
return;
end

I ask for 33 ties, in a row of (0/1/0), distance 1, and I only get 4 (excluding the origin). I have a total of 141 things so there should be room for 33 new objects.

/Edward
Edward's Cognative Hazards

↑ Up to the top!