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

有帮助吗?

解决方案

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?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top