0

Okay, so I'm trying to use Javascript to make a Game (Engine?Maybe...). Unfortunately, that means no extremely detailed library like in Visual C#...

So I'm wondering, if I have vector (which is just two variables for right now) and I make that a scalar(multiply those two numbers) then how to i find the min and the max of this scalar?

C#/XNA has a built in Min() and Max(), but I'm trying to do this in Javascript I couldn't seem to find anything on this site, the similar questions on the side don't seem to be of any help... I don't have any code for you because I'm not sure where to start... can someone please help?

Vectors and Scalars

Mat
  • 202,337
  • 40
  • 393
  • 406
pandavenger
  • 1,017
  • 7
  • 20
  • ... unless I am seriously confused, a scalar is a single value so the notion of min and max of a scalar makes no sense. What do you really mean? – hackartist Jan 15 '12 at 02:48
  • hackartist, see the two links i put up, this isn't the scalar used in computing, it's the mathematical term (basically a vector multiplied by something) – pandavenger Jan 15 '12 at 03:01

1 Answers1

2

Javascript also has built in Max and Min functions, e.g.,

var bigNum = Math.max(1,2,3,4,5);

These can be extended to get Max and Min values in arrays (vectors). See this question: JavaScript: min & max Array values?

Community
  • 1
  • 1
lubar
  • 2,589
  • 2
  • 26
  • 28
  • sooo... do I just find the min and max out of the two values of the scalar? that sounds simplistic enough... It looked like higher level math so I was really confused (I'm taking Pre-Calc this year, I'm in High School) – pandavenger Jan 15 '12 at 02:59