Wc3C.net Vector
 Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar

07-12-2011, 12:42 PM   #46
Anitarf
Procrastination Incarnate

Development Director

Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Quote:
 Originally Posted by Bribe Is there a way to rotate a vector considering the Z value with the rotation? I suspect not in this library, based on that it's only rotating the X and Y. I wonder what kind of complexity we'd deal with if we had to factor in all three dimensions into the equations.
I'm not sure what you mean by that, but this library is capable of rotating a vector around any axis, whether it's vertical or pointing sideways.

Quote:
 I'm also unsure of what the purpose of "terrainNormal" is. It takes four corners into consideration but what if the center is a bit indented/raised offset from the rest?
That doesn't really matter. The purpose of the function is to get a vector perpendicular to the terrain surface. Sure, the results get smoothed in some cases (as you move across a terrain grid line, the actual terrain normal will change instantly while the one returned by Vector will change gradually) but in most cases you'd want that anyway and if not you can always use a very small sample radius.
__________________
 Cinema Workshop released! Let's make some cinematics! Editor's version of the winner of the Blizzard's Cinematic Contest: The Spirit of Vengeance

 10-23-2011, 05:42 PM #47 BBQ User   Join Date: May 2011 Posts: 85 Submissions (2) I think that a including a createFromUnit() (or something like that) static method wouldn't be that bad - especially for projectile systems that use vectors (such as this one).
 10-24-2011, 01:49 AM #48 busterkomo User   Join Date: Aug 2007 Posts: 68 Submissions (1) What do you mean by creating a vector from a unit?
 10-24-2011, 10:52 AM #49 BBQ User   Join Date: May 2011 Posts: 85 Submissions (2) Zinc:```static method createFromUnit(unit whichUnit, real heightOffset) -> vector { vector v = vector.allocate(); real x = GetUnitX(whichUnit), y = GetUnitY(whichUnit); MoveLocation(thistype.loc, x, y); v.x = x; v.y = y; v.z = GetUnitFlyHeight(whichUnit) + GetLocationZ(thistype.loc) + heightOffset; return v; }``` Something along those lines. Last edited by BBQ : 10-24-2011 at 10:53 AM.
10-24-2011, 04:38 PM   #50
Anitarf
Procrastination Incarnate

Development Director

Join Date: Feb 2004
Posts: 8,190

Submissions (19)

You can already do this with the following two lines, I don't think that a wrapper for this is really needed:
JASS:
```local vector v = vector.createTerrainPoint( GetUnitX(whichUnit), GetUnitY(whichUnit) )
set v.z = v.z + GetUnitFlyHeight(whichUnit) + heightOffset```
__________________
 Cinema Workshop released! Let's make some cinematics! Editor's version of the winner of the Blizzard's Cinematic Contest: The Spirit of Vengeance