How to define the new vector in my case?

  • Context: Undergrad 
  • Thread starter Thread starter mellon
  • Start date Start date
  • Tags Tags
    Vector
Click For Summary
SUMMARY

The discussion focuses on generating N sub-vectors from an origin vector using the JavaScript Vector class. The origin vector is defined as origin = new Vector(x, y), and sub-vectors are created by adding a new vector Vector(m, n) to the origin. To ensure that the distance between neighboring sub-vectors is a specified length L, the values of m and n must be derived from the direction of the line represented by the origin vector. The solution involves using linear algebra concepts to calculate unit vectors and their corresponding positions along the line.

PREREQUISITES
  • Understanding of vector mathematics and linear algebra
  • Familiarity with JavaScript and object-oriented programming
  • Knowledge of parametric equations in coordinate systems
  • Experience with vector manipulation in programming
NEXT STEPS
  • Study the implementation of vector classes in JavaScript
  • Learn about unit vectors and their applications in geometry
  • Explore parametric equations and their use in defining lines
  • Research algorithms for generating evenly spaced points along a line
USEFUL FOR

Software developers, particularly those working with graphics programming, game development, or any field requiring vector mathematics and spatial calculations.

mellon
Messages
1
Reaction score
0
If I have a vector:

origin = new Vector(x, y)

then, I would like to get N sub vectors, each one of the N sub vector is got by adding origin vector with a new vector value like:

subVector = origin.add(new Vector(m, n));

The result I would like to achieve is showing in the image below:

http://i.stack.imgur.com/ZvH1j.png"

I would like to get N sub vectors which are in the same horizontal level and spaced by "L" length,

My questions are:

1. what is the new vector (Vector(m, n)) m, n values I should use to get all the sub vectors ? (N is dynamic value)

I end up with something like:

for(var i=0; i<N; i++){

//But, how to select the m, n value ??
var subVector = origin.add(new Vector(m, n));

}



2. How the choose the new vector (Vector(m, n)) m, n value to make sure the distance between two neighboring sub vectors is L as showed in the image ?
 
Last edited by a moderator:
Physics news on Phys.org
Are you talking about Linear Algebra or programming? It looks to me like you do not have a "vector" and "subvectors" but that you start with a line line and want to find position vectors of points on that line, with distance between them equal to L.

If, in some coordinate system, you line is given by parametric equation x= at+ b, y= ct+ d, and you have a given starting point on the line, with postion vector [itex]\ve{v}_0[/itex], then a vector pointing along the line is [itex]a\vec{i}+ b\vec{j}[/itex]. That has length [itex]\sqrt{a^2+ b^2}[/itex] so that [itex](1/\sqrt{a^2+ b^2})(a\vec{i}+ b\vec{j})[/itex] is a unit vector.

For simplicity, let [itex]a'= a/\sqrt{a^2+ b^2}[/itex] and [itex]b'= b/\sqrt{a^2+ b^2}[/itex] so the unit vector in the direction of the line is [itex]a'\vec{i}+ b'\vec{j}[/itex]. n points on that line, starting with [itex]\vec{v}_0[/itex], with distance L between them, are given by [itex]\vec{v}_0+ Li(a'\vec{i}+ b'\vec{j})[/itex] with i ranging from 0 to n-1.
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 27 ·
Replies
27
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K