Related
I would like to test the pairwise similarity between 22 study sites (rows) using the simprof function in the 'clustsig' package in R.
It is based on Clarke, Somerfield, and Gorley (2008), who developed SIMPROF, a “similarity profile,” which represents the matrix of pairwise similarity values between any set of objects. The data represent percent cover of benthic organisms on a coral reef with each row summing to 100.
Using a matrix with more than 20 rows, I get the following error,
"Error in if (denom != 0) { : missing value where TRUE/FALSE needed"
I do not get this error with 20 rows or less.
Any guidance or possible explanation for this error would be appreciated.
install.packages("clustsig")
require(clustsig)
mdat2 <- matrix(
c(2.0, 3.0, 32.3, 0.0, 2.3, 43.7, 0.3, 0.3, 2.0, 0.0, 13.7, 0.3, #1
16.9, 0.0, 4.5, 0.0, 12.4, 36.9, 0.0, 0.7, 0.7, 5.9, 21.0, 1.0, #2
28.3, 0.0, 7.3, 0.0, 21.7, 12.9, 0.0, 0.0, 0.7, 4.2, 21.7, 3.1, #3
4.1, 2.0, 31.8, 0.0, 6.1, 31.1, 3.0, 0.7, 5.7, 0.3, 15.2, 0.0, #4
13.1, 0.7, 46.3, 0.3, 0.0, 1.7, 0.3, 0.0, 0.3, 0.3, 36.9, 0.0, #5
1.3, 23.7, 55.5, 9.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 9.4, 0.3, #6
4.1, 0.7, 27.9, 0.7, 3.1, 32.1, 14.5, 0.0, 4.8, 0.0, 11.0, 1.0, #7
1.0, 4.7, 68.9, 0.0, 1.0, 11.8, 3.4, 0.3, 2.4, 0.0, 6.1, 0.3, #8
8.2, 0.0, 49.1, 0.0, 0.7, 5.5, 0.0, 0.3, 0.3, 0.0, 32.3, 3.4, #9
17.8, 2.4, 48.8, 0.0, 0.3, 2.0, 3.0, 0.0, 11.1, 0.0, 13.8, 0.7, #10
17.3, 0.4, 30.0, 5.1, 0.0, 18.1, 0.0, 1.1, 5.8, 0.0, 21.7, 0.7, #11
8.1, 1.0, 62.3, 0.0, 3.0, 4.0, 0.0, 0.0, 0.7, 0.0, 19.2, 1.7, #12
12.8, 0.0, 65.9, 0.3, 0.0, 1.0, 0.0, 0.0, 0.7, 0.0, 17.9, 1.4, #13
16.3, 4.2, 46.7, 0.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 31.5, 0.7, #14
24.9, 0.0, 15.4, 0.0, 0.3, 2.0, 0.3, 0.7 ,2.7, 0.0, 50.9, 2.7, #15
19.8, 0.0, 35.1, 0.0, 0.0, 2.1, 1.4, 0.7, 1.4, 0.0, 39.2, 0.3, #16
14.2, 0.0, 48.1, 0.0, 0.3, 11.2, 0.0, 0.0, 1.0, 0.0, 24.1, 1.0, #17
25.0, 0.7, 27.4, 0.3, 0.7, 28.0, 0.0, 1.0, 6.1, 0.0, 10.1, 0.7, #18
7.4, 0.3, 41.1, 0.0, 0.0, 27.4, 0.3, 0.3, 10.7, 0.0, 11.7, 0.7, #19
8.7, 5.4, 63.4, 2.0, 0.0, 1.0, 0.0, 0.0, 1.3, 0.0, 17.8, 0.3, #20
15.9, 0.0, 34.2, 0.0, 2.7, 6.4, 0.3, 1.7, 2.7, 0.0, 34.2, 1.7, #21
5.1, 1.7, 60.3, 1.0, 1.0, 3.0, 0.0, 0.0, 2.0, 0.0, 25.9, 0.0 #22
),
nrow = 22, ncol = 12, byrow = TRUE,
dimnames = list(c("row1", "row2", "row3", "row4", "row5",
"row6", "row7", "row8", "row9", "row10",
"row11", "row12", "row13", "row14", "row15",
"row16", "row17", "row18", "row19",
"row20", "row21", "row22"
),
c("c.1", "c.2", "c.3", "c.4", "c.5", "c.6",
"c.7", "c.8", "c.9", "c.10", "c.11", "c.12")
)
)
mdat2.simprof <- simprof(mdat2,
num.expected = 1000, num.simulated = 999,
method.distance = "actual-braycurtis",
method.transform = "identity", alpha = 0.05,
sample.orientation = "row", const = 1,
silent = FALSE, increment = 100,
undef.zero = TRUE, warn.braycurtis = TRUE)
I am learning the Qt 3D module. I found the Qt.matrix4x4 provide different API than QMatrix4x4 in C++ side (by using F1 check the API doc).
look likes Qt.matrix4x4 don't have such scale or rotation operations. even not in autocomplete.
BUT! these functions do exist and work!
var m = Qt.matrix4x4(1, 0, 0, -0.5, 0, 1, 0, 0, 0, 0, 1, 0.5, 0, 0, 0, 1)
m.scale(2)
console.log(m)
// qml: QMatrix4x4(2, 0, 0, -0.5, 0, 2, 0, 0, 0, 0, 2, 0.5, 0, 0, 0, 1)
// the type shows QMatrix4x4
https://doc.qt.io/qt-5/qmatrix4x4.html vs https://doc.qt.io/qt-5/qml-matrix4x4.html
I understand what these is, But why the API show different in API doc and autocomplete?
It is interesting to note that in Qt6 the documentation appears different than Qt5. In Qt6 we see clearly there are methods for constructing the matrix4x4 basic type from a vector and for multiplying them with vectors.
// translate(vector3d)
var m = Qt.matrix4x4();
m.translate(Qt.vector3d(1,2,3));
console.log(m.toString());
// QMatrix4x4(1, 0, 0, 1, 0, 1, 0, 2, 0, 0, 1, 3, 0, 0, 0, 1)
// matrix multiplication
var m = Qt.matrix4x4();
m.translate(Qt.vector3d(1,2,3));
console.log(m.toString());
// QMatrix4x4(1, 0, 0, 1, 0, 1, 0, 2, 0, 0, 1, 3, 0, 0, 0, 1)
// applying a matrix to a vector
var a = Qt.matrix4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
var b = Qt.vector3d(5,6,7);
var c = a.times(b);
console.log(c.toString()); // QVector3D(0.155556, 0.437037, 0.718518)
Note I tried all of the above in Qt5.15.6 but it doesn't work. So it appears that support for this type really kicks in at Qt6.
For further information see: https://doc.qt.io/qt-6/qml-matrix4x4.html
everyone. I have an issue in converting VRML to A-frame.
VRML has the "Geometry ElevationGrid" function to set the DEM value of the texture.
Instance code is as follows.
geometry ElevationGrid {
xDimension 9
zDimension 9
xSpacing 1.0
zSpacing 1.0
solid FALSE
height [
0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 2.5, 0.5, 0.0, 0.0, 0.0,
0.0, 0.0, 0.5, 0.5, 3.0, 1.0, 0.5, 0.0, 1.0,
0.0, 0.0, 0.5, 2.0, 4.5, 2.5, 1.0, 1.5, 0.5,
1.0, 2.5, 3.0, 4.5, 5.5, 3.5, 3.0, 1.0, 0.0,
0.5, 2.0, 2.0, 2.5, 3.5, 4.0, 2.0, 0.5, 0.0,
0.0, 0.0, 0.5, 1.5, 1.0, 2.0, 3.0, 1.5, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 1.5, 0.5,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0,
]
}
I tried to convert this above VRML ElevationGrid code to Aframe.
But I can't find how to do it. Please help me if anyone knows.
This can be done, but it is a complex topic. Aframe does not have the equivalent of an elevation grid. But aframe is simply a framework for working with THREEjs, and THREE does have way to generate a mesh from scratch, and displace its height. Explaining it is far beyond the scope of this response, but take a look at this tutorial on THREEjs fundamentals. It walks through the entire process.
https://threejsfundamentals.org/threejs/lessons/threejs-custom-geometry.html
Eric Eisenman (aka Sir FizX, on the AFrame slack) has written a terrain component and made it public. It uses a vertex shader, and is a very beautiful (and fast) implementation of generated terrain. Here it is on glitch.
https://glitch.com/~aframe-terrain
Can I change the size of polygon wchich I defined by points?
var pierwszy = new Kinetic.Polygon({
points: [0, 0, 150, 0, 80, 150, 0, 150],
fillPatternImage: images.img1,
stroke: 'black',
strokeWidth: 5,
});
I have tried to just change points and add to tween atriubutes, but it doesn't work.
scaleX and scaleY work very well, but the background image is bluring.
Any ideas?
I don't know if this is useful for you,In my situation is ,I want to change the shape of the polygon with a tween:
poly1= new Kinetic.Polygon({
points: [0, 0, 150, 0, 80, 150, 0, 150],
fill: shadowLightColor,
stroke: '#bbbbbb',
strokeWidth: 1
});
layer.add(poly1);
poly1.tween = new Kinetic.Tween({
node: poly1,
duration: 1,
points: [0, 0, 300, 0, 200, 150, 0, 150],
easing: Kinetic.Easings.StrongEaseInOut
}).play();
This is weird, and I can't find anything like it online. I am rendering a reflective sphere in OpenGL, and I'm trying to reposition the camera and use glCopytexImage2D to render directly to the Cube Map textures. Problem is, my reflective sphere ends up reflecting everything on my desktop EXCEPT the OpenGL environment! How does something like this even happen? It's tripping me out. I will include my entire renderReflectiveSphere function here:
void drawReflectiveSphere(){
float sphere_pos[] = {10.0, 0.0, -40.0};
glMatrixMode(GL_MODELVIEW);
glDisable(GL_TEXTURE_2D);
glPushMatrix();
//Positive x
gluLookAt(sphere_pos[0], sphere_pos[1], sphere_pos[2],
sphere_pos[0] + 1, sphere_pos[1], sphere_pos[2],
0.0, 1.0, 0.0);
glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGB, -128, -128, 128, 128, 0);
//Negative x
gluLookAt(sphere_pos[0], sphere_pos[1], sphere_pos[2],
sphere_pos[0] - 1, sphere_pos[1], sphere_pos[2],
0.0, 1.0, 0.0);
glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGB, -128, -128, 128, 128, 0);
//Positive y
gluLookAt(sphere_pos[0], sphere_pos[1], sphere_pos[2],
sphere_pos[0], sphere_pos[1] + 1, sphere_pos[2],
0.0, 0.0, 1.0);
glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGB, -128, -128, 128, 128, 0);
//Negative y
gluLookAt(sphere_pos[0], sphere_pos[1], sphere_pos[2],
sphere_pos[0], sphere_pos[1] - 1, sphere_pos[2],
0.0, 0.0, 1.0);
glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGB, -128, -128, 128, 128, 0);
//Positive z
gluLookAt(sphere_pos[0], sphere_pos[1], sphere_pos[2],
sphere_pos[0], sphere_pos[1], sphere_pos[2] + 1,
0.0, 1.0, 0.0);
glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGB, -128, -128, 128, 128, 0);
//Negative z
gluLookAt(sphere_pos[0], sphere_pos[1], sphere_pos[2],
sphere_pos[0], sphere_pos[1], sphere_pos[2] - 1,
0.0, 1.0, 0.0);
glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGB, -128, -128, 128, 128, 0);
glPopMatrix();
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glEnable(GL_TEXTURE_CUBE_MAP);
glPushMatrix();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(sphere_pos[0], sphere_pos[1], sphere_pos[2]);
gluSphere(quadratic, 5.0f, 128, 128);
glPopMatrix();
//Reset frustrum, etc.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, depth + 15.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_GEN_R);
glDisable(GL_TEXTURE_CUBE_MAP);
glDrawBuffer(GL_BACK);
glReadBuffer(GL_BACK);
}
I assume I'm doing a few things wrong, but where would OpenGL get the contents of my desktop from? And how can I set myself straight to do what I want?
I eventually solved this but the problem is in code not shown above. Essentially, I initialized my cube map texture to a size much too large.