Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Amanda Ghassaei
DMDesign
Commits
6e2823c2
Commit
6e2823c2
authored
Aug 18, 2015
by
Amanda Ghassaei
Browse files
motion vectors in simulation code
parent
8fb43768
Changes
3
Hide whitespace changes
Inline
Side-by-side
js/cam/assemblers/Assembler.js
View file @
6e2823c2
...
...
@@ -339,11 +339,12 @@ define(['underscore', 'appState', 'lattice', 'stlLoader', 'threeModel', 'cam', '
if
(
totalThreads
>
0
)
return
;
callback
();
}
var
startingPos
=
{
x
:
this
.
components
.
xAxis
.
getPosition
().
x
,
y
:
this
.
components
.
yAxis
.
getPosition
().
y
,
z
:
this
.
components
.
zAxis
.
getPosition
().
z
};
speed
=
this
.
_normalizeSpeed
(
startingPos
,
position
,
new
THREE
.
Vector3
(
speed
,
speed
,
speed
));
this
.
components
.
xAxis
.
moveTo
(
this
.
_makeAxisVector
(
position
,
"
x
"
),
speed
.
x
,
sketchyCallback
);
this
.
components
.
yAxis
.
moveTo
(
this
.
_makeAxisVector
(
position
,
"
y
"
),
speed
.
y
,
sketchyCallback
);
this
.
components
.
zAxis
.
moveTo
(
this
.
_makeAxisVector
(
position
,
"
z
"
),
speed
.
z
,
sketchyCallback
);
var
startingPos
=
this
.
components
.
zAxis
.
getAbsolutePosition
();
//get position of end effector
speed
=
this
.
_normalizeSpeed
(
startingPos
,
position
,
new
THREE
.
Vector3
(
speed
,
speed
,
speed
));
//todo fix this
this
.
components
.
xAxis
.
moveTo
(
position
,
speed
.
x
,
sketchyCallback
);
this
.
components
.
frame
.
moveTo
(
position
,
speed
.
y
,
sketchyCallback
);
this
.
components
.
zAxis
.
moveTo
(
position
,
speed
.
z
,
sketchyCallback
);
};
Assembler
.
prototype
.
_normalizeSpeed
=
function
(
startingPos
,
position
,
speed
){
//todo make this more general
...
...
js/cam/assemblers/Component.js
View file @
6e2823c2
...
...
@@ -84,6 +84,30 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
return
this
.
object3D
.
position
.
clone
();
};
Component
.
prototype
.
getAbsolutePosition
=
function
(){
if
(
!
this
.
parent
)
return
this
.
getPosition
();
return
this
.
parentObject
.
getAbsolutePosition
().
add
(
this
.
parentObject
.
applyRotation
(
this
.
getPosition
()));
};
Component
.
prototype
.
getOrientation
=
function
(){
return
this
.
object3D
.
quaternion
.
clone
();
};
Component
.
prototype
.
getAbsoluteOrientation
=
function
(){
if
(
!
this
.
parent
)
return
this
.
getOrientation
();
return
this
.
getOrientation
().
multiply
(
this
.
parentObject
.
getAbsoluteOrientation
());
//order matters!
};
Component
.
prototype
.
applyRotation
=
function
(
vector
){
//todo local rotation?
vector
.
applyQuaternion
(
this
.
getAbsoluteOrientation
());
return
vector
;
};
Component
.
prototype
.
applyAbsoluteRotation
=
function
(
vector
){
vector
.
applyQuaternion
(
this
.
getAbsoluteOrientation
());
return
vector
;
};
Component
.
prototype
.
setTranslucent
=
function
(
translucent
){
if
(
this
.
stl
===
undefined
)
return
;
this
.
stl
.
material
.
transparent
=
translucent
;
...
...
@@ -145,10 +169,12 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
};
Component
.
prototype
.
moveTo
=
function
(
target
,
speed
,
callback
){
var
target
=
this
.
_multiplyVectors
(
target
,
this
.
motionVector
);
if
(
target
===
null
){
if
(
callback
)
callback
();
return
;
}
var
currentPosition
=
this
.
getPosition
();
var
increment
=
speed
/
1500.0
*
cam
.
get
(
"
simSpeed
"
);
var
incrVector
=
target
.
clone
().
sub
(
currentPosition
);
...
...
@@ -163,6 +189,14 @@ define(['underscore', 'cam', 'three'], function(_, cam, THREE){
this
.
_incrementalMove
(
incrVector
,
target
,
callback
);
};
Component
.
prototype
.
_multiplyVectors
=
function
(
target
,
motion
){
if
(
target
.
x
===
null
&&
motion
.
x
>
0
)
return
null
;
if
(
target
.
y
===
null
&&
motion
.
y
>
0
)
return
null
;
if
(
target
.
z
===
null
&&
motion
.
z
>
0
)
return
null
;
var
target
=
new
THREE
.
Vector3
(
target
.
x
,
target
.
y
,
target
.
z
);
return
target
.
multiply
(
motion
);
};
Component
.
prototype
.
_incrementalMove
=
function
(
increment
,
target
,
callback
){
var
self
=
this
;
setTimeout
(
function
(){
...
...
js/plists/CamPList.js
View file @
6e2823c2
...
...
@@ -41,7 +41,6 @@ define(['three'], function(THREE){
xAxis
:
{
name
:
"
X Axis
"
,
rotary
:
false
,
axisOfMotion
:
null
,
//minBound
//maxBound
parent
:
"
yAxis
"
,
...
...
@@ -56,7 +55,6 @@ define(['three'], function(THREE){
frame
:
{
name
:
"
Y Axis
"
,
rotary
:
false
,
axisOfMotion
:
null
,
//minBound
//maxBound
parent
:
"
substrate
"
,
...
...
@@ -68,7 +66,6 @@ define(['three'], function(THREE){
zAxis
:
{
name
:
"
Z Axis
"
,
rotary
:
false
,
axisOfMotion
:
null
,
//minBound
//maxBound
parent
:
"
xAxis
"
,
...
...
@@ -80,7 +77,6 @@ define(['three'], function(THREE){
yAxis
:
{
name
:
"
Frame
"
,
rotary
:
false
,
axisOfMotion
:
null
,
//minBound
//maxBound
parent
:
"
frame
"
,
...
...
@@ -92,8 +88,7 @@ define(['three'], function(THREE){
substrate
:
{
name
:
"
Substrate
"
,
rotary
:
true
,
axisOfMotion
:
null
,
centerOfRotation
:
{
x
:
10
,
y
:
10
,
z
:
0
},
//(5.08mm, 5.715mm)
centerOfRotation
:
{
x
:
4
,
y
:
4.5
,
z
:
0
},
//(5.08mm, 5.715mm)
//minBound
//maxBound
parent
:
null
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment