Specific vector scaling

Blitz3D Forums/Blitz3D Programming/Specific vector scaling

big10p(Posted 2007) [#1]
Say I have a vector x:2,y:0 as in diagram 1, then I rotate it 45 degrees, as in diagram 2. Is there any way to scale the vector to match the blue vector (i.e. so the end of the vector is directly on the grid cell boundary)?




Gabriel(Posted 2007) [#2]
Can you just clarify what are variables and what are constants here? Will the x component of the vector always be 2? will the y component always be 0? Will the rotation always be 45 degrees? Will it always be clockwise? Will the gridline you want it aligned to always be a multiple of 1?


Wings(Posted 2007) [#3]
You ned to calculate what each Y value is worth.

this is usfull if one builds a ray tracer engine to detect walls.

I dont remember this clear but i think sin and cos is neded


Stevie G(Posted 2007) [#4]
Simple line intersection will resolve this.


big10p(Posted 2007) [#5]
Actually, forget about this - I've since realized what I was trying to do is nonsense. :/

Another approach to solving the problem this is involved with has since occured to me, which should simplify things greatly. Gah, I spent hours yesterday racking my brains and even resorted to writing 'square' sin/cos functions. I think I need a new hobby more suitable for my ageing brain...