Text archives Help
- From: sparker@sci.utah.edu
- To: rtrt@sci.utah.edu
- Subject: [MANTA] r284 - in branches/newPointVector: Core/Geometry Engine/Control Model/Cameras StandAlone UserInterface scenes
- Date: Tue, 10 May 2005 23:42:06 -0600 (MDT)
Author: sparker
Date: Tue May 10 23:42:05 2005
New Revision: 284
Modified:
branches/newPointVector/Core/Geometry/AffineTransform.cc
branches/newPointVector/Core/Geometry/AffineTransform.h
branches/newPointVector/Engine/Control/RTRT.cc
branches/newPointVector/Model/Cameras/PinholeCamera.cc
branches/newPointVector/StandAlone/CMakeLists.txt
branches/newPointVector/UserInterface/XWindowUI.cc
branches/newPointVector/scenes/primtest.cc
Log:
Partially implemented Moller/Hughes from/to rotation
Removed extraneous print statements
Read .dylib files for the mac
Modified: branches/newPointVector/Core/Geometry/AffineTransform.cc
==============================================================================
--- branches/newPointVector/Core/Geometry/AffineTransform.cc (original)
+++ branches/newPointVector/Core/Geometry/AffineTransform.cc Tue May 10
23:42:05 2005
@@ -83,6 +83,7 @@
const VectorT<T, 3>& to_)
{
+#if 0
// Compute an axis ortho to the two vectors.
VectorT<T,3> axis = Cross( from_, to_ );
@@ -104,6 +105,44 @@
rotate( axis, theta );
// Otherwise no rotation.
+#endif
+ VectorT<T, 3> v = Cross(from_, to_);
+ T e = Dot(from_, to_);
+ T f = SCIRun::Abs(e);
+ if(f > 1.0-1.e-9){
+ return;
+#if 0
+ Vector x(-SCIRun::Abs(from_.x()), -SCIRun::Abs(from_.y()),
-SCIRun::Abs(from_.z()));
+ if(x.x() < x.y()){
+ if(x.x() < x.z()){
+ x[0] = 1; x[1] = x[2] = 0;
+ } else {
+ x[2] = 1; x[0] = x[1] = 0;
+ }
+ } else {
+ if(x.y() < x.z()){
+ x[1] = 1; x[0] = x[2] = 0;
+ } else {
+ x[2] = 1; x[0] = x[1] = 0;
+ }
+ }
+#endif
+ } else {
+ T mtx[3][3];
+ T h = 1.0/(1.0 + e); /* optimization by Gottfried Chen */
+ mtx[0][0] = e + h * v[0] * v[0];
+ mtx[0][1] = h * v[0] * v[1] - v[2];
+ mtx[0][2] = h * v[0] * v[2] + v[1];
+
+ mtx[1][0] = h * v[0] * v[1] + v[2];
+ mtx[1][1] = e + h * v[1] * v[1];
+ mtx[1][2] = h * v[1] * v[2] - v[0];
+
+ mtx[2][0] = h * v[0] * v[2] - v[1];
+ mtx[2][1] = h * v[1] * v[2] + v[0];
+ mtx[2][2] = e + h * v[2] * v[2];
+ pre_multiply(mtx);
+ }
}
template<typename T>
@@ -311,48 +350,60 @@
template<typename T>
VectorT<T, 3> operator*(const AffineTransformT<T>& trans, const VectorT<T,
3>& vec) {
- VectorT<T,3> result;
- for (int i=0;i<3;++i) {
- result[i] = trans(i,0) * vec[0];
- result[i] += trans(i,1) * vec[1];
- result[i] += trans(i,2) * vec[2];
- // vec[3] == 0
- }
- return result;
+ VectorT<T,3> result;
+ for (int i=0;i<3;++i) {
+ result[i] = trans(i,0) * vec[0];
+ result[i] += trans(i,1) * vec[1];
+ result[i] += trans(i,2) * vec[2];
+ // vec[3] == 0
+ }
+ return result;
}
// Multiply by the transpose of the AffineTransformation, useful for
// computations involving an inverse transpose.
template<typename T>
PointT<T, 3> transpose_mult(const AffineTransformT<T>& trans, const
PointT<T, 3>& point) {
- PointT<T,3> result;
- for (int i=0;i<3;++i) {
- result[i] = trans(0,i) * point[0];
- result[i] += trans(1,i) * point[1];
- result[i] += trans(2,i) * point[2];
- result[i] += trans(3,i); // point[3] == 1
- }
- return result;
+ PointT<T,3> result;
+ for (int i=0;i<3;++i) {
+ result[i] = trans(0,i) * point[0];
+ result[i] += trans(1,i) * point[1];
+ result[i] += trans(2,i) * point[2];
+ result[i] += trans(3,i); // point[3] == 1
+ }
+ return result;
}
template<typename T>
VectorT<T, 3> transpose_mult(const AffineTransformT<T>& trans, const
VectorT<T, 3>& vec) {
- VectorT<T,3> result;
+ VectorT<T,3> result;
+ for (int i=0;i<3;++i) {
+ result[i] = trans(0,i) * vec[0];
+ result[i] += trans(1,i) * vec[1];
+ result[i] += trans(2,i) * vec[2];
+ // vec[3] == 0
+ }
+ return result;
+ }
+
+ template<typename T>
+ std::ostream &operator << ( std::ostream &os, const AffineTransformT<T>
&trans ) {
for (int i=0;i<3;++i) {
- result[i] = trans(0,i) * vec[0];
- result[i] += trans(1,i) * vec[1];
- result[i] += trans(2,i) * vec[2];
- // vec[3] == 0
+ for (int j=0;j<4;++j) {
+ os << trans(i,j) << " ";
+ }
+ os << std::endl;
}
- return result;
+ return os;
}
+
// Static Instances.
template PointT <Real,3> operator*(const AffineTransformT<Real> &trans,
const PointT <Real,3> &point);
template VectorT<Real,3> operator*(const AffineTransformT<Real> &trans,
const VectorT<Real,3> &vec);
template PointT <Real,3> transpose_mult(const AffineTransformT<Real>
&trans, const PointT <Real,3> &point);
template VectorT<Real,3> transpose_mult(const AffineTransformT<Real>
&trans, const VectorT<Real,3> &vec);
template class AffineTransformT<Real>;
-
+ template std::ostream& operator<<(std::ostream& os, const
AffineTransformT<Real>& trans);
}
Modified: branches/newPointVector/Core/Geometry/AffineTransform.h
==============================================================================
--- branches/newPointVector/Core/Geometry/AffineTransform.h (original)
+++ branches/newPointVector/Core/Geometry/AffineTransform.h Tue May 10
23:42:05 2005
@@ -2,8 +2,6 @@
#ifndef Manta_Core_AffineTransform_h
#define Manta_Core_AffineTransform_h
-#include <iostream>
-
#include <MantaTypes.h>
#include <Core/Geometry/PointVector.h>
@@ -26,13 +24,17 @@
~AffineTransformT() {
}
- // Use the default version of these.
- // AffineTransformT(const AffineTransformT<T> ©) {
- // memcpy(mat,copy.mat, sizeof(T)*12);
- // }
- // AffineTransformT<T>& operator=(const AffineTransformT<T> ©) {
- // memcpy(mat,copy.mat, sizeof(T)*12);
- //}
+ AffineTransformT(const AffineTransformT<T> ©) {
+ for(int i=0;i<3;i++)
+ for(int j=0;j<4;j++)
+ mat[i][j] = copy.mat[i][j];
+ }
+ AffineTransformT<T>& operator=(const AffineTransformT<T> ©) {
+ for(int i=0;i<3;i++)
+ for(int j=0;j<4;j++)
+ mat[i][j] = copy.mat[i][j];
+ return *this;
+ }
// These methods set the current matrix
void initWithIdentity();
@@ -70,46 +72,26 @@
private:
T mat[3][4];
- // Pre-multiplication.
+ // Pre-multiplication.
void pre_multiply(T m[3][3]);
};
template<typename T>
- PointT<T, 3> operator*(const AffineTransformT<T>& trans,
- const
PointT<T, 3>& point);
+ PointT<T, 3> operator*(const AffineTransformT<T>& trans, const PointT<T,
3>& point);
template<typename T>
- VectorT<T, 3> operator*(const AffineTransformT<T>& trans,
- const
VectorT<T, 3>& vec);
+ VectorT<T, 3> operator*(const AffineTransformT<T>& trans, const VectorT<T,
3>& vec);
// Multiply by the transpose of the AffineTransformation, useful for
// computations involving an inverse transpose.
template<typename T>
- PointT<T, 3> transpose_mult(const AffineTransformT<T>& trans,
-
const PointT<T, 3>& point);
+ PointT<T, 3> transpose_mult(const AffineTransformT<T>& trans, const
PointT<T, 3>& point);
template<typename T>
- VectorT<T, 3> transpose_mult(const AffineTransformT<T>& trans,
-
const VectorT<T, 3>& vec);
+ VectorT<T, 3> transpose_mult(const AffineTransformT<T>& trans, const
VectorT<T, 3>& vec);
template<typename T>
- std::ostream &operator << ( std::ostream &os, const AffineTransformT<T>
&trans ) {
- for (int i=0;i<3;++i) {
- for (int j=0;j<4;++j) {
- os << trans(i,j) << " ";
- }
- os << std::endl;
- }
- return os;
- }
+ std::ostream &operator << ( std::ostream &os, const AffineTransformT<T>
&trans );
}
-
-
-
-// #ifdef __GNUG__
-// This should instead be a configure variable...
-// Look in the bottom of AffineTransform.cc for explicit instantiations.
-// #include <Core/Geometry/AffineTransform.cc>
-// #endif
#endif
Modified: branches/newPointVector/Engine/Control/RTRT.cc
==============================================================================
--- branches/newPointVector/Engine/Control/RTRT.cc (original)
+++ branches/newPointVector/Engine/Control/RTRT.cc Tue May 10 23:42:05
2005
@@ -929,7 +929,7 @@
std::cout << "Scene suffix: " << suffix << std::endl;
- if((suffix == "mo") || (suffix == "so")) {
+ if((suffix == "mo") || (suffix == "so") || (suffix == "dylib")) {
// Do this twice - once silently and once printing errors
std::cout << "Reading .mo or .so scene" << std::endl;
Modified: branches/newPointVector/Model/Cameras/PinholeCamera.cc
==============================================================================
--- branches/newPointVector/Model/Cameras/PinholeCamera.cc (original)
+++ branches/newPointVector/Model/Cameras/PinholeCamera.cc Tue May 10
23:42:05 2005
@@ -11,9 +11,6 @@
#include <Core/Util/Assert.h>
#include <iostream>
-// Required for up direction error condition.
-#include <iostream>
-
using namespace Manta;
using namespace std;
using SCIRun::Clamp;
@@ -150,28 +147,13 @@
Vector lookdir(eye-lookat);
double length = lookdir.length();
- std::cout << "incoming transform: " << std::endl << t << std::endl;
- std::cout << "lookdir: " << lookdir << std::endl;
- std::cout << "v: " << v << std::endl;
- std::cout << "u: " << u << std::endl;
-
AffineTransform frame;
frame.initWithBasis(v.normal(), u.normal(), lookdir.normal(), cen);
- std::cout << "frame" << std::endl << frame << std::endl;
-
AffineTransform frame_inv = frame;
frame_inv.invert();
- std::cout << "frame_inv" << std::endl << frame_inv << std::endl;
-
AffineTransform t2 = frame * t * frame_inv;
-
- std::cout << "Should be frame: " << std::endl << (frame * t) <<
std::endl;
- std::cout << "Should be identity: " << std::endl << (frame * frame_inv) <<
std::endl;
-
- std::cout << "t2" << std::endl << t2 << std::endl;
-
up = t2 * up;
eye = t2 * eye;
lookat = t2 * lookat;
Modified: branches/newPointVector/StandAlone/CMakeLists.txt
==============================================================================
--- branches/newPointVector/StandAlone/CMakeLists.txt (original)
+++ branches/newPointVector/StandAlone/CMakeLists.txt Tue May 10 23:42:05
2005
@@ -12,10 +12,3 @@
${OPENGL_LIBRARIES}
${X11_LIBRARIES}
-lm)
-
-ADD_EXECUTABLE(transformtest transformtest.cc)
-TARGET_LINK_LIBRARIES(transformtest
- Manta_Core
- SCIRun_Core)
-
- TARGET_LINK_LIBRARIES(transformtest -lm)
Modified: branches/newPointVector/UserInterface/XWindowUI.cc
==============================================================================
--- branches/newPointVector/UserInterface/XWindowUI.cc (original)
+++ branches/newPointVector/UserInterface/XWindowUI.cc Tue May 10 23:42:05
2005
@@ -497,17 +497,13 @@
Vector to(projectToSphere(xpos, ypos, trackball_radius));
AffineTransform trans;
- trans.initWithRotation(ias.rotate_from, to);
-
- std::cout << "Sent to callback: " << std::endl << trans <<
std::endl;
- std::cout << "Small rotation: " << (trans * Point(1,0,0)) <<
std::endl;
-
+ trans.initWithRotation(to, ias.rotate_from);
ias.rotate_from = to;
Camera* camera = rtrt_interface->getCamera(channel);
rtrt_interface->addTransaction("rotate",
Callback::create(camera,
&Camera::transform,
-
trans,
Camera::LookAt));
+ trans, Camera::LookAt));
ias.last_x = mouse_x;
ias.last_y = mouse_y;
}
Modified: branches/newPointVector/scenes/primtest.cc
==============================================================================
--- branches/newPointVector/scenes/primtest.cc (original)
+++ branches/newPointVector/scenes/primtest.cc Tue May 10 23:42:05 2005
@@ -83,7 +83,7 @@
Group* group = new Group();
Material* matl;
- int max = Max(numx, numy);
+ int max = SCIRun::Max(numx, numy);
if(material == "redphong")
matl=new Phong(Color(RGB(.6,0,0)), Color(RGB(.6,.6,.6)), 32, 0.4);
else if(material == "redlambertian")
@@ -153,10 +153,10 @@
spinprim = new Sphere(matl, Point(0,0,0), scale/max);
} else if(primtype == "box"){
Point p2(scale/max/1.732, scale/max/1.732, scale/max/1.732);
- spinprim = new Cube(matl, -p2, p2.x()*2, p2.y()*2, p2.z()*2);
+ spinprim = new Cube(matl, Point(-p2.x(), -p2.y(), -p2.z(), p2.x()*2,
p2.y()*2, p2.z()*2);
} else if(primtype == "intersection"){
Point p2(scale/max/1.414, scale/max/1.414, scale/max/1.414);
- Primitive* o1 = new Cube(matl, -p2, p2.x()*2, p2.y()*2, p2.z()*2);
+ Primitive* o1 = new Cube(matl, Point(-p2.x(), -p2.y(), -p2.z(),
p2.x()*2, p2.y()*2, p2.z()*2);
Primitive* o2 = new Sphere(matl, Point(0,0,0), scale/max);
SphericalMapper* map = new SphericalMapper(Point(0,0,0), scale/max);
o1->setTexCoordMapper(map);
@@ -164,7 +164,7 @@
spinprim = new Intersection(o1, o2);
} else if(primtype == "difference"){
Point p2(scale/max/1.414, scale/max/1.414, scale/max/1.414);
- Primitive* o1 = new Cube(matl, -p2, p2.x()*2, p2.y()*2, p2.z()*2);
+ Primitive* o1 = new Cube(matl, Point(-p2.x(), -p2.y(), -p2.z()),
p2.x()*2, p2.y()*2, p2.z()*2);
Primitive* o2 = new Sphere(matl, Point(0,0,0), scale/max);
double s = scale/max/1.414*2*(1+1.e-10);
LinearMapper* map = new LinearMapper(Point(0,0,0),
@@ -185,12 +185,12 @@
Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
(j/static_cast<double>(numy-1) - 0.5)*scale*2,
0);
- Transform t;
+ AffineTransform t;
double a1 = i/static_cast<double>(numx-1)*M_PI*2;
double a2 = j/static_cast<double>(numy-1)*M_PI*2;
- t.pre_rotate(a1, Vector(0,1,0));
- t.pre_rotate(a2, Vector(1,0,0));
- t.pre_translate(p);
+ t.rotate(a1, Vector(0,1,0));
+ t.rotate(a2, Vector(1,0,0));
+ t.translate(p);
group->add(new InstanceRT(spinprim, t));
}
}
@@ -231,15 +231,15 @@
Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
(j/static_cast<double>(numy-1) - 0.5)*scale*2,
0);
- Transform t;
+ AffineTransform t;
double a1 = i/static_cast<double>(numx-1)*M_PI*2;
double a2 = j/static_cast<double>(numy-1)*M_PI*2;
int idx = j*numx+i;
double scale = (idx+1)/static_cast<double>(numx*numy);
- t.pre_scale(Vector(scale, scale, scale));
- t.pre_rotate(a1, Vector(0,1,0));
- t.pre_rotate(a2, Vector(1,0,0));
- t.pre_translate(p);
+ t.scale(Vector(scale, scale, scale));
+ t.rotate(a1, Vector(0,1,0));
+ t.rotate(a2, Vector(1,0,0));
+ t.translate(p);
group->add(new InstanceRST(spinprim, t));
}
}
@@ -249,15 +249,15 @@
Vector p((i/static_cast<double>(numx-1) - 0.5)*scale*2,
(j/static_cast<double>(numy-1) - 0.5)*scale*2,
0);
- Transform t;
+ AffineTransform t;
double a1 = i/static_cast<double>(numx-1)*M_PI*2;
double a2 = j/static_cast<double>(numy-1)*M_PI*2;
int idx = j*numx+i;
double scale = (idx+1)/static_cast<double>(numx*numy);
- t.pre_scale(Vector(scale, scale, scale));
- t.pre_rotate(a1, Vector(0,1,0));
- t.pre_rotate(a2, Vector(1,0,0));
- t.pre_translate(p);
+ t.scale(Vector(scale, scale, scale));
+ t.rotate(a1, Vector(0,1,0));
+ t.rotate(a2, Vector(1,0,0));
+ t.translate(p);
group->add(new Instance(spinprim, t));
}
}
- [MANTA] r284 - in branches/newPointVector: Core/Geometry Engine/Control Model/Cameras StandAlone UserInterface scenes, sparker, 05/10/2005
Archive powered by MHonArc 2.6.16.