| further reading | more topics » |
| mjbWorld program | 3D theory |
3D physics |
3D maths |
3D programming | technology |
about site |
sitemap A-Z |
| index | algebra | geometry | calculus | graph theory | statistics | principles | standards |
| index | equations | vector | matrix | complex | clifford | groups |
| index | applications | related | angle between | look at | code |
/*Title: mjbWorld
Copyright (c) 1998-2007 Martin John BakerThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General public: License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General public: License for more details.For information about the GNU General public: License see http://www.gnu.org/To discuss this program http://sourceforge.net/forum/forum.php?forum_id=122133 also see website http://www.euclideanspace.com/ *//* for theory see: http://www.euclideanspace.com/maths/vectors/index.htm */__gc class sfvec2f : public property {//double x,y; static bool saveAsDouble = false ; public: double x; public: double y; // VRML only supports float but allow override if higher resolution required public: sfvec2f(); public: sfvec2f(float x1,float y1); public: sfvec2f(sfvec2f* p);// public: sfvec2f(Point2f p); public: String* vrmlType(); public: static String* vrmlType_s(){ return "SFVec2f"; } public: property* clone(); /** create an array of the appropriate type * with a size given by the parameter */ public: property* createArray(int size)[]; /** get a single value * inst = instance number * nb = nodeBean this property is contained in - only used in case this is * in a PROTO and parameter has an IS value */ public: property* get(int inst,nodeBean* nb); public: void set(property* in,int inst);/** output as a string * mode values * 0 - output modified values * 1 - output original values * 2 - output attribute * 3 - output attribute in brackets * 4 - output with f prefix */ public: String* outstring(int format); public: bool Equals(sfvec2f* v2); /** write to file * filter = information about output * mode values * 0 - output VRML97 modified values * 1 - output VRML97 original values * 2 - output xml (x3d) * 3 - output attribute in brackets * 4 - output with f prefix */ public: void write(filter* f,int mode,int indent); public: String* toStatic(); /** used by mfparam.vrml2par */ public: bool instring(filter* f,sfparam* sfp,nodeBean* n,int mode); public: bool instring(filter* f,String* s1); public: static Type* getEditClass(){ return __typeof(sfvec2fEditor); }};
/*Title: mjbWorld
Copyright (c) 1998-2002 Martin John BakerThis program is free software; you can redistribute it and/or modify it under the terms of the GNU General License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General License for more details.For information about the GNU General License see http://www.gnu.org/To discuss this program http://sourceforge.net/forum/forum.php?forum_id=122133 also see website http://www.euclideanspace.com/ *//* for theory see: http://www.euclideanspace.com/maths/vectors/index.htm */#include "mjbModel.h" /* x3d definition<!ENTITY % SFVec2f "CDATA"> <!-- ArrayList2Float --> */ // VRML only supports float but allow override if higher resolution requiredsfvec2f::sfvec2f() { saveAsDouble = false ; }sfvec2f::sfvec2f(float x1,float y1) { saveAsDouble = false ; x=x1; y=y1; }sfvec2f::sfvec2f(sfvec2f* p) { saveAsDouble = false ; x=p->x; y=p->y; }String* sfvec2f::vrmlType(){ return "SFVec2f"; }property* sfvec2f::clone() { //Console::WriteLine("sfvec2f->clone"); return new sfvec2f(this); }/** create an array of the appropriate type * with a size given by the parameter */ property* sfvec2f::createArray(int size)[]{ return new sfvec2f*[size]; }/** get a single value * inst = instance number * nb = nodeBean this property is contained in - only used in case this is * in a PROTO and parameter has an IS value */ property* sfvec2f::get(int inst,nodeBean* nb) { return this; }void sfvec2f::set(property* in,int inst) { x = (dynamic_cast<sfvec2f*>(in))->x; y = (dynamic_cast<sfvec2f*>(in))->y; }bool sfvec2f::Equals(sfvec2f* v2) { if (!v2) return false; if (x!= v2->x) return false; if (y!= v2->y) return false; return true; }/** output as a string * mode values * 0 - output modified values * 1 - output original values * 2 - output attribute * 3 - output attribute in brackets * 4 - output with f prefix */ String* sfvec2f::outstring(int format) { if (format == 3) { if (saveAsDouble) return String::Concat(S"(",__box(x)->ToString(), S" ",__box(y)->ToString(),S")"); else return String::Concat(S"(",__box((float)x)->ToString(), S" ",__box((float)y)->ToString(),S")"); } else if (format == 4) { return String::Concat(__box(x)->ToString(),S"f,", __box(y)->ToString(),S"f"); } else { if (saveAsDouble) return String::Concat(__box(x)->ToString(), S" ",__box(y)->ToString()); else return String::Concat(__box((float)x)->ToString(), S" ",__box((float)y)->ToString()); } }/** write to file * filter = information about output * mode values * 0 - output VRML97 modified values * 1 - output VRML97 original values * 2 - output xml (x3d) * 3 - output attribute in brackets * 4 - output with f prefix */ void sfvec2f::write(filter* f,int mode,int indent){ //Console::WriteLine("mfvec2f->write(f,"+mode+","+indent+")"); f->write(outstring(mode)); }String* sfvec2f::toStatic() { return String::Concat(__box(x)->ToString(),S"f,", __box(y)->ToString(),S"f"); }/** used by mfparam->vrml2par */ bool sfvec2f::instring(filter* f,sfparam* sfp,nodeBean* n,int mode) { String* s; try { s=f->nextToken(); if (s) if (s->Equals("IS")) { s=f->nextToken(); if (sfp) sfp->setIs(s); return true; } x = Single::Parse(s); s=f->nextToken(); y = Single::Parse(s); } catch (Exception* e) { Console::WriteLine("sfvec2f->instring error: {0}",e); } return true; }bool sfvec2f::instring(filter* f,String* s1) { String* s; try { x = Single::Parse(s1); s=f->nextToken(); y = Single::Parse(s); } catch (Exception* e) { Console::WriteLine("sfvec2f->instring error: {0}",e); } return true; }
|
metadata block |
|
| see also: |
|
| Correspondence about this page | |
|
Book Shop - Further reading. Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them. |
|
|
Commercial Software Shop Where I can, I have put links to Amazon for commercial software, not directly related to the software project, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them. |
|
Can you help? Please send me any improvements to here. I would appreciate ideas to make the pages more useful including error correction, ideas for new pages, improvements to wording. It helps if you quote the full URL of the page. |
|
|
Terminology and Notation Specific to this page here: |
|
|
program I am working on a project which uses these principles, if you would like to help me with this you are welcome to join in, here: |
|
This site may have errors. Don't use for critical systems.
Copyright (c) 1998-2008 Martin John Baker - All rights reserved - privacy policy.