w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How do I convert this for loop into something cooler like by in R
A more vectorized (== cooler?) version would pull the common operations out of the loop and let R do the book-keeping about unique factor levels. dat <- split(-2 * log(as.numeric(file[,10])), file[,12]) names(dat) <- paste0("IoOPanos_filtered_on_pc_", names(dat)) (paste0 is a convenience function for the common use case where normally one would use paste with the argument sep=""). The for loop is entirely appropriate when you're running it for its side effects (plotting pretty pictures) rather than trying to capture values for further computation; it's definitely un-cool to use T instead of TRUE, while seq_along(dat) means that your code won't produce unexpected results when length(dat) == 0. pdf("SKAT.pdf") for(i in seq_along(dat)) { vals <- dat[[i]] nm <- names(da

Categories : R

Water jug puzzle in SWI-Prolog
in Prolog, it make little sense to output the action 'description', because any sequence of actions that will fail will be undone, thus trying any available alternative. Then the first step I would take is a 'cosmetic one' : move away the description, that can be inferred from two adjacent steps of a solution (the list Z), and add a Solution argument to maneuver. Another important improvement: all your steps repeat the same - wrong - pattern: for instance + member(Z, (4,Y)), append(Z, [(4,Y)], A) make a 'subroutine' (and correct the mistake, that - I think - leads to the loop): update(State, Step, Updated) :- + member(Step, State), append(State, [Step], Updated).

Categories : Prolog

Webgl: Water effect in 2D
Use several textures, like bluish for water, black-and-white caustics for caustics and stone texture for floor. Then write fragment shader that would distort textures over time and simulate different effects you're up to. Hope this helps.

Categories : Javascript

Water 2D wave effect in JavaFX
In this tutorial you can find how to use custom GLSL/HLSL pixel shaders for JavaFX. And the code for a simple distortion procedural wave in screenSpace in HLSL form: uniform extern texture ScreenTexture; sampler ScreenS = sampler_state { Texture = <ScreenTexture>; }; float wave; // pi/.75 is a good default float distortion; // 1 is a good default float2 centerCoord; // 0.5,0.5 is the screen center float4 PixelShader(float2 texCoord: TEXCOORD0) : COLOR { float2 distance = abs(texCoord - centerCoord); float scalar = length(distance); // invert the scale so 1 is centerpoint scalar = abs(1 - scalar); // calculate how far to distort for this pixel float sinoffset = sin(wave / scalar); sinoffset = clamp(sinoffse

Categories : Java

ZMQ high water mark deprecated on 3.x.x?
Have a look at: http://zeromq.org/docs:3-1-upgrade In zeromq 3.2 HWM has been split into send and receive high water mark: ZMQ_SNDHWM and ZMQ_RCVHWM. The functions you are looking for in jzmq are: long getRcvHWM() long getSndHWM() void setRcvHWM(long rcvHWM) void setSndHWM(long sndHWM)

Categories : Scala

Three.js Retrieve data from WebGLRenderTarget (water sim)
Ok, I figured out how to read the data using native webgl calls: // Render first scene into texture renderer.render( sceneRTT, cameraRTT, rtTexture, true ); // read render texture into buffer var gl = renderer.getContext(); gl.readPixels( 0, 0, simRes, simRes, gl.RGBA, gl.UNSIGNED_BYTE, buf1.image.data ); buf1.needsUpdate = true; The simulation now animates. However, it doesn't seem to be functioning properly (probably a dumb error I'm overlooking). It seems that the height values are never being damped and I'm not sure why. The data from buf1 is used in the fragment shader, which calculates the new height (red in RGBA), damps the value (multiplies by 0.99), then renders it to a texture. I then read this updated data from the texture back into buf1. Here's the latest fiddle: http://j

Categories : Three Js

random perlinNoise in AS3 (for water ripple effect)
I think only applying the effect on random parts or partially each frame will look strange (I think you will see the "cheating"). Have you tried generating a displacement map image with half the resolution of the picture and then scale it up (with smoothing turned on) before using it as a displacement map? Maybe the lower resolution won't be that noticeable?

Categories : Actionscript

Drag div by leading point (like a boat in water)
You need to: Store position each time it changes At change, calculate the angle of the line between said positions Save last position http://jsfiddle.net/AstDerek/799Tp/ Movement doesn't look soft but is closer to what you want. If you want to simulate water drag, you'd need to reduce the angle change by some factor, then use some time interval or similar to continue movement after dragging has ended, until the angle of the ship matches the angle it should have, or a new drag event starts.

Categories : Jquery

SQL - daily water consumption. Difference between days
since the consumption is never going to decrease (hour to next hour), can you not take MAX(consumption) - MIN(consumption) for each date? Update: You may have to do MIN(consumption_today) - MIN(consumption_yesterday) to include and account for all consumption that happened between last reading of yesterday and first reading of today.

Categories : SQL

What's wrong with this code water boiling project
Your form is submitting to the current page. You should probably move your fill() to onsubmit for the form. Also, make sure that function returns false, or the form will still submit.

Categories : Javascript

Magento Water Mark ONLY in Zoom Images
You can use magento default watermarks option no need to code, go to Configuration >> Design >> Product image watermarks here you can assign watermarks to any OR all Product images. As you said you dont want watermarks on thumbnails but you havn't mentioned the images you are usning for product page, by default Base image is used for product page.

Categories : Magento

Water ripple - The image cannot load on first time
A common error when this type of issue occurs, is that you are trying to draw the image before it loads. Try utilizing the img.onload function to wait until the image has loaded to do all of the drawing and then to start running the main loop.

Categories : Javascript

Water ripple effect on background of website
Have a look on these 2 demos, which i think you can get based to create yours. 29a.ch and mrdoob Hope this helps

Categories : Javascript

Android Gridlayout: Add new views always on high-water-mark
UPDATE: Using the new RecyclerView and the StaggeredGridViewLayoutManager you can achieve this now without third-party libs. OLD ANSWER: I found out that this kind of View was already done by Google under the name of StaggeredGridView. It was once in the AOSP, but was taken out again (I lost the source for this info...but anyway). But you can find a modified version of StaggeredGridView here: https://github.com/maurycyw The original Google source is here: https://github.com/friberry/StaggeredGridView/blob/9c4582ab8e79294ab60f63277e2a54c58e74b372/src/com/origamilabs/library/views/StaggeredGridView.java And another very good implementation of it is found in the official Etsy App. The code was made public: https://github.com/etsy/AndroidStaggeredGrid

Categories : Android

Storing water in buckets smartly - algorithm suggestions?
This can be treated as a max flow problem. Create a source node, a sink node and nodes for each jug and each bucket, and add an edge from the source to each jug with capacity equal to the amount of water in that jug. Add edges with infinite capacity between allowed jug/bucket pairs and add an edge from each bucket to the sink node with capacity equal to the capacity of the bucket. Now find the max flow. If it's equal to the total amount of water then you have a solution.

Categories : Algorithm

OpenCV - calibrate camera using static images in water
To calibrate the camera you do need multiple images of the checkerboard (or one of the other patterns found here). What you can do, is calibrate the camera outside of the water or do a calibration sequence once. Once you have that information (focal length, center of lens, distortion, etc). You can use the solvePNP function to estimate the orientation of a single board. This estimation provides you with a distance from the camera to the board. A completely different alternative could be to find what kind of lens the camera uses and manually fill in the data. I've not tried this, so I'm uncertain how well this would work.

Categories : Opencv

Water mark in register form using mvc4/razor
Placeholders are a client-side feature, and has nothing to do with the server-side platform you're using. In HTML5, you can use the placeholder="" attribute, like so: <input type="text" placeholder="First name" /> In ASP.NET MVC, you can add the attribute like so: Html.InputFor( m => m.FirstName, new { placeholder="First name" } ) IE8 does not support placeholders, but you can emulate them with a number of jQuery and Mootools add-ons that replicate the functionality.

Categories : Asp Net Mvc



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.