This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > VRML > December 2004 > Obtain dimensions....
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Obtain dimensions....
|
|
| bensmyth 2004-12-24, 12:15 pm |
| This is difficult to explain, so I'll cut-to-the-chase....
Is there a way to write the following js function:
function vectorLength(vector)
{
var length = 0;
for (var i = 0; i < vector.LENGTH; i++)
length += vector[i];
length = Math.sqrt(length);
return length;
}
vector.LENGTH is obviously undefined...... vector could be either SFVec3f or
SFVec2f or ...... is there a dynamic method to get the length??? (I'm
assuming not.... but thought I might as well ask!)
Cheers,
Ben
| |
| Josip Almasi 2004-12-24, 12:15 pm |
| bensmyth wrote:
> This is difficult to explain, so I'll cut-to-the-chase....
>
> Is there a way to write the following js function:
>
> function vectorLength(vector)
> {
> var length = 0;
>
> for (var i = 0; i < vector.LENGTH; i++)
> length += vector[i];
>
> length = Math.sqrt(length);
>
> return length;
> }
>
>
> vector.LENGTH is obviously undefined...... vector could be either SFVec3f or
> SFVec2f or ...... is there a dynamic method to get the length??? (I'm
> assuming not.... but thought I might as well ask!)
Yep, length() method, RTFM, ECMAScript part of VRML97 spec:
Table C.10 -- SFVec2f functions
Function Description
SFVec2f add(SFVec2f vec) Returns the value of the passed value added,
component-wise, to the object.
SFVec2f divide(numeric n) Returns the value of the object divided by
the passed value.
numeric dot(SFVec2f vec) Returns the dot product of this vector and the
passed value.
numeric length( ) Returns the geometric length of this vector.
SFVec2f multiply(numeric n) Returns the value of the object multiplied
by the passed value.
SFVec2f normalize( ) Returns the object converted to unit length .
SFVec2f subtract(SFVec2f vec) Returns the value of the passed value
subtracted, component-wise, from the object.
String toString( ) Returns a String containing the ISO/IEC 14772 UTF-8
encoded value of x and y.
Table C.12 -- SFVec3f functions
Function Description
SFVec3f add(SFVec3f vec) Returns the value of the passed value added,
component-wise, to the object.
SFVec3f cross(SFVec3f vec) Returns the cross product of the object and
the passed value.
SFVec3f divide(numeric n) Returns the value of the object divided by
the passed value.
numeric dot(SFVec3f vec) Returns the dot product of this vector and the
passed value.
numeric length( ) Returns the geometric length of this vector.
SFVec3f multiply(numeric n) Returns the value of the object multiplied
by the passed value.
SFVec3f negate( ) Returns the value of the component-wise negation of
the object.
SFVec3f normalize( ) Returns the object converted to unit length .
SFVec3f subtract(SFVec3f vec) Returns the value of the passed value
subtracted, component-wise, from the object.
String toString( ) Returns a String containing the ISO/IEC 14772 UTF-8
encoded value of x, y, and z.
Regards...
| |
| bensmyth 2004-12-24, 7:16 pm |
| > Yep, length() method, RTFM, ECMAScript part of VRML97 spec:
Wasn't exactly what I was asking for....
But, is FAR BETTER!!!
Thanks,
Ben
| |
| bensmyth 2004-12-27, 7:15 am |
| > Yep, length() method, RTFM, ECMAScript part of VRML97 spec:
Wasn't exactly what I was asking for....
But, is FAR BETTER!!!
Thanks,
Ben
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|