New answers tagged vector
1
This is known as a line-drawing algorithm. That link has multiple algorithms to solve this problem - for your case you'll want to ignore the algorithms which anti-alias. The simplest solution is the naive algorithm:
dx = x2 − x1
dy = y2 − y1
for x from x1 to x2 do
y = y1 + dy × (x − x1) / dx
plot(x, y)
(pseudocode copied from wikipedia)
A more ...
answered yesterday
BlueRaja - Danny Pflughoeft
7,62822 gold badges3131 silver badges4141 bronze badges
3
Check if the point you get is on the far half-circle, and if it is, mirror it.
Radius = 5;
_randomDirection = (Vector3)(Random.insideUnitCircle).normalized;
Vector3 toTarget = _target.position - _source.position;
if (Vector3.Dot(toTarget, _randomDirection) > 0f) {
_randomDirection = Vector3.Reflect(_randomDirection, toTarget);
}
Vector3 ...
Top 50 recent answers are included
Related Tags
vector × 660mathematics × 170
unity × 152
c# × 98
rotation × 78
2d × 68
c++ × 53
linear-algebra × 52
3d × 51
physics × 50
xna × 47
movement × 46
matrix × 42
java × 39
collision-detection × 33
quaternion × 32
angles × 28
libgdx × 23
opengl × 22
geometry × 22
direction × 20
transformation × 18
raycasting × 17
camera × 16
coordinates × 15